CN112765676B - Intelligent contract executing method, intelligent contract executing device and node equipment - Google Patents
Intelligent contract executing method, intelligent contract executing device and node equipment Download PDFInfo
- Publication number
- CN112765676B CN112765676B CN202011395356.1A CN202011395356A CN112765676B CN 112765676 B CN112765676 B CN 112765676B CN 202011395356 A CN202011395356 A CN 202011395356A CN 112765676 B CN112765676 B CN 112765676B
- Authority
- CN
- China
- Prior art keywords
- byte code
- enhanced
- intelligent contract
- code file
- field
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q10/00—Administration; Management
- G06Q10/10—Office automation; Time management
- G06Q10/101—Collaborative creation, e.g. joint development of products or services
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F21/00—Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
- G06F21/60—Protecting data
- G06F21/64—Protecting data integrity, e.g. using checksums, certificates or signatures
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q50/00—Information and communication technology [ICT] specially adapted for implementation of business processes of specific business sectors, e.g. utilities or tourism
- G06Q50/10—Services
- G06Q50/18—Legal services
Landscapes
- Engineering & Computer Science (AREA)
- Business, Economics & Management (AREA)
- Theoretical Computer Science (AREA)
- Human Resources & Organizations (AREA)
- Strategic Management (AREA)
- General Physics & Mathematics (AREA)
- Entrepreneurship & Innovation (AREA)
- Physics & Mathematics (AREA)
- Tourism & Hospitality (AREA)
- General Health & Medical Sciences (AREA)
- General Business, Economics & Management (AREA)
- Computer Security & Cryptography (AREA)
- Marketing (AREA)
- Health & Medical Sciences (AREA)
- Economics (AREA)
- General Engineering & Computer Science (AREA)
- Bioethics (AREA)
- Primary Health Care (AREA)
- Technology Law (AREA)
- Computer Hardware Design (AREA)
- Software Systems (AREA)
- Data Mining & Analysis (AREA)
- Operations Research (AREA)
- Quality & Reliability (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
The application is applicable to the technical field of computers, and provides an intelligent contract executing method, an intelligent contract executing device and node equipment, wherein the method comprises the following steps: receiving a calling request for calling an intelligent contract, and acquiring a byte code file corresponding to the intelligent contract; if the byte code file corresponding to the intelligent contract is an enhanced byte code file, marking a persistence field of the intelligent contract as a first state, wherein the persistence field is a field of which a corresponding value is stored in a blockchain ledger, the enhanced byte code file is a byte code file containing enhanced byte code instructions, and the enhanced byte code instructions are used for reading the value of the persistence field in the first state from the blockchain ledger; and executing the byte code file corresponding to the intelligent contract by using a virtual machine to finish the response to the call request. By the method, the Java virtual machine can read the value of the persistence field of the intelligent contract from the blockchain ledger through a single byte code instruction.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to an intelligent contract execution method, an intelligent contract execution apparatus, a node device, and a computer readable storage medium.
Background
An intelligent contract is a computer protocol that aims to propagate, verify, and/or execute contracts in an informative manner. Currently, the execution engines of smart contracts include ethernet virtual machines and Java virtual machines. The two virtual machines internally realize respective exclusive virtual machine instruction sets, and byte codes generated after the intelligent contracts are compiled by the compiler can be executed on the virtual machines. The Ethernet virtual machine is a virtual machine developed by the Ethernet aiming at solidity intelligent contracts, a sload instruction exists in a virtual machine instruction set of the Ethernet virtual machine, the value of a state variable of the intelligent contract stored in a blockchain account book can be directly read, and a similar instruction does not exist in a virtual machine instruction set of the Java virtual machine.
Disclosure of Invention
In view of the above, the present application provides an intelligent contract execution method, an intelligent contract execution apparatus, a node device, and a computer-readable storage medium, which enable a Java virtual machine to read the value of the persistence field of an intelligent contract from a blockchain ledger through a single bytecode instruction.
In a first aspect, the present application provides an intelligent contract execution method, including:
Receiving a calling request for calling the intelligent contract, and acquiring a byte code file corresponding to the intelligent contract;
if the byte code file corresponding to the intelligent contract is an enhanced byte code file, marking a persistence field of the intelligent contract as a first state, wherein the persistence field is a field of which a corresponding value is stored in a blockchain ledger, the enhanced byte code file is a byte code file containing enhanced byte code instructions, and the enhanced byte code instructions are used for reading the value of the persistence field in the first state from the blockchain ledger;
and executing the byte code file corresponding to the intelligent contract by using the virtual machine to complete the response to the call request.
In a second aspect, the present application provides an intelligent contract execution apparatus, including:
the acquisition unit is used for receiving a calling request for calling the intelligent contract and acquiring a byte code file corresponding to the intelligent contract;
The processing unit is used for marking a persistence field of the intelligent contract as a first state if the byte code file corresponding to the intelligent contract is an enhanced byte code file, wherein the persistence field is a field of which a corresponding value is stored in a blockchain account book, the enhanced byte code file is a byte code file containing enhanced byte code instructions, and the enhanced byte code instructions are used for reading the value of the persistence field in the first state from the blockchain account book;
and the execution unit is used for executing the byte code file corresponding to the intelligent contract by using the virtual machine so as to complete the response to the call request.
In a third aspect, the present application provides a node device comprising a memory, a processor and a computer program stored in said memory and executable on said processor, said processor implementing the method as provided in the first aspect when executing said computer program.
In a fourth aspect, the present application provides a computer readable storage medium storing a computer program which, when executed by a processor, implements a method as provided in the first aspect.
From the above, in the present application, a call request for calling an intelligent contract is received, first, a byte code file corresponding to the intelligent contract is obtained, if the byte code file corresponding to the intelligent contract is an enhanced byte code file, a first preprocessing is performed on a persistence field of the intelligent contract, the persistence field is a field with a corresponding value stored in a blockchain ledger, the enhanced byte code file is a byte code file containing an enhanced byte code instruction, the enhanced byte code instruction is used for reading a value of the persistence field after the first preprocessing from the blockchain ledger, and finally, a virtual machine is used to execute the byte code file corresponding to the intelligent contract to complete the call. The scheme of the application utilizes byte code enhancement to enhance the byte code instructions in the byte code files corresponding to the intelligent contracts, and can enable the Java virtual machine to read the values of the persistence fields of the intelligent contracts from the blockchain account book through the single enhanced byte code instructions. It will be appreciated that the advantages of the second to fourth aspects may be found in the relevant description of the first aspect and are not repeated here.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments or the description of the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a smart contract execution method provided by an embodiment of the present application;
FIG. 2 is a schematic diagram of an enhanced bytecode instruction according to an embodiment of the present application;
FIG. 3 is a block diagram of an intelligent contract executing apparatus according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a node device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in the present description and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
Furthermore, the terms "first," "second," "third," and the like in the description of the present specification and in the appended claims, are used for distinguishing between descriptions and not necessarily for indicating or implying a relative importance.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
Fig. 1 is a flowchart of an intelligent contract executing method according to an embodiment of the present application, where the intelligent contract executing method is applied to a node device in a blockchain system, and is described in detail as follows:
Step 101, receiving a call request for calling the intelligent contract, and obtaining a byte code file corresponding to the intelligent contract.
In the embodiment of the application, a user can send a call request to node equipment through a user terminal, wherein the call request is used for calling the intelligent contract. When the node device receives the call request, the node device can acquire the byte code file corresponding to the intelligent contract. Illustratively, the call request carries the address contractAddress of the smart contract, the name of the method being called, and the parameters of the method. The node equipment is operated with a Java virtual machine, and the Java virtual machine can acquire a byte code file corresponding to the intelligent contract from the blockchain account book according to the address of the intelligent contract.
And 102, if the byte code file corresponding to the intelligent contract is the enhanced byte code file, marking the persistence field of the intelligent contract as a first state.
In the embodiment of the application, the byte code file can be loaded into the Java virtual machine through a custom class loader. The class loader can analyze the byte code file and identify the byte code file of the intelligent contract main body class. The intelligent contract main body class inherits from the abstract class of the infrastructure of the intelligent contract, realizes the abstract method in the abstract class, and contains the life cycle control function of the intelligent contract. The class loader can judge whether the byte code file corresponding to the intelligent contract is an enhanced byte code file or not through the byte code file of the intelligent contract main body class. Wherein the enhanced byte code file is a byte code file containing enhanced byte code instructions. The enhanced byte code instruction is a custom instruction and does not belong to a virtual machine instruction set of a Java virtual machine. The Java virtual machine may read the value of the persistence field in the first state from the blockchain ledger by executing the enhanced bytecode instruction. The persistent field is a field in which the corresponding value needs to be stored in the blockchain ledger in a persistent manner. Thus, if the bytecode file corresponding to the smart contract is an enhanced bytecode file, the persistence field of the smart contract may be marked as a first state in order that the Java virtual machine may subsequently read the value of the persistence field from the blockchain ledger by executing the enhanced bytecode instruction.
Illustratively, the enhanced bytecode instructions include custom getstorefield enhanced instructions and getstorestatic enhanced instructions, getstorefield enhanced instructions may be consistent with the structure of getfield instructions in the virtual machine instruction set of the Java virtual machine, getstorestatic enhanced instructions may be consistent with the structure of getstatic instructions in the virtual machine instruction set of the Java virtual machine. Specifically, referring to FIG. 2, the enhanced bytecode instruction includes two parts, an opcode and a field entry index, respectively. Wherein the opcode occupies one byte and is used to identify the type of the enhanced bytecode instruction, i.e., an operation indicating what nature the enhanced bytecode instruction should perform. The field entry index occupies two bytes and is used to point to a symbolic reference to a field of a constant pool of bytecode files, i.e., the CONSTANT _fieldref_info structure in the constant pool in the bytecode files defined in the Java virtual machine specification. Wherein getstorefield the enhanced instruction is to read the value of the persistence field in the first state in the contract object from the blockchain ledger, getstorestatic the enhanced instruction is to read the value of the static persistence field in the first state in the smart contract body class from the blockchain ledger.
Optionally, after the step 101, before the step 102, the method further includes:
detecting whether a constant pool of a byte code file corresponding to the intelligent contract contains an enhancement identifier or not;
And if the constant pool contains the enhancement identifier, determining the byte code file corresponding to the intelligent contract as the enhancement byte code file.
In the embodiment of the application, a preset enhancement identifier can be added in a constant pool of the enhancement byte code file. The class loader can judge whether the byte code file is an enhanced byte code file by detecting whether the constant pool of the byte code file corresponding to the intelligent contract contains the enhanced identifier. Specifically, if the constant pool of the byte code file corresponding to the intelligent contract contains the enhancement identifier, determining that the byte code file is an enhancement byte code file. And if the constant pool of the byte code file corresponding to the intelligent contract does not contain the enhancement identifier, determining that the byte code file is not the enhancement byte code file.
Illustratively, the augmentation identifier may be a preset constant (denoted as augmentation constant) that may be added to the constant pool of bytecode files of the smart contract body class. It should be appreciated that before adding the enhanced constant items to the constant pool, the size of the constant pool needs to be increased by 1, for example, the original constant pool size is s, and the constant pool size should be modified to s+1 so that the Java virtual machine can learn the number of the constant items in the constant pool. Further, to enable the enhanced constant item to be found from the constant pool more quickly, the enhanced constant item may also be added to a specified location in the constant pool, such as the end item of the constant pool. Based on the above, the class loader can detect whether the end item of the constant pool of the byte code file of the intelligent contract main body class is the enhanced constant item in the byte code file corresponding to the intelligent contract, and if the end item is the enhanced constant item, the byte code file corresponding to the intelligent contract can be considered as the enhanced byte code file.
Optionally, in order to ensure information security, security check may be performed on the enhanced frequent item, and only if the security check passes, the Java virtual machine may consider the bytecode file corresponding to the intelligent contract as the enhanced bytecode file. For example, in view of the subsequent potential update of the smart contract, the enhanced bytecode instruction may have multiple versions, and in the enhanced frequent item, version information indicating the version of the enhanced bytecode instruction may be included in addition to the original data for identification purposes. If the end item of the constant pool of the byte code file of the intelligent contract body class is an enhanced constant item, version information included in the enhanced constant item can be obtained to identify the version of the enhanced byte code instruction contained in the intelligent contract, if the Java virtual machine does not support the enhanced byte code instruction of the version, the security check is not passed, and if the Java virtual machine supports the enhanced byte code instruction of the version, the security check is passed.
Optionally, the step 102 specifically includes:
If the byte code file corresponding to the intelligent contract is the enhanced byte code file, constructing a contract object of the intelligent contract by the virtual machine through the byte code file corresponding to the intelligent contract;
obtaining all fields of the contract object by using a reflection mechanism;
initializing values of non-persistent fields in all fields;
The persisted field in all fields is marked as a first state.
In the embodiment of the application, if the byte code file corresponding to the intelligent contract is an enhanced byte code file, the Java virtual machine can call a parameter-free construction method to construct a contract object of the intelligent contract based on the byte code file of the intelligent contract main body class; all fields of the contract object may then be obtained through the Java reflection mechanism. All fields of the contract object include a persistent field and a non-persistent field, wherein the non-persistent field is a field except the persistent field in all fields. The Java virtual machine may initially combine the values of the non-persistent fields in all fields of the constraint object, i.e., assign a default value for the non-persistent field to the corresponding data type, such as a default 0 value for the non-persistent field to the corresponding data type. For persistent fields in all fields, each persistent field may be marked as a first state, e.g., the first state is an unloaded state, indicating that the value of a persistent field has not been loaded into memory if the persistent field is in an unloaded state.
It should be noted that, if the bytecode file corresponding to the smart contract is an enhanced bytecode file, in a subsequent process of executing the bytecode file, an enhanced bytecode instruction for obtaining a value of a certain persistence field may be executed. When executing the enhanced bytecode instruction, it may be determined whether the persistence field is in an unloaded state, and if so, the value of the persistence field is read from the blockchain ledger. By the method, lazy loading of the persistent field is realized, memory overhead is reduced, and execution efficiency is improved.
Illustratively, after obtaining all fields of the contract object using the reflection mechanism, all fields of the contract object may be traversed, and for the currently traversed fields, the attributes thereof may be parsed, and whether preset persistence annotations exist in the attributes may be detected. And if the corresponding field traversed currently has the preset persistence annotation, determining the field traversed currently as a persistence field. If the currently traversed field does not have the persistence annotation, the currently traversed field is determined to be a non-persistence field. Optionally, before traversing all the fields, a persistent field state table may be newly built in the memory, if a preset persistent annotation exists in the corresponding field traversed currently, the field traversed currently is identified as a key, unloaded as a value, and the key value pair is used as a record to be inserted into the persistent field state table, so that the fact that the field traversed currently is marked as an unloaded state is achieved. Alternatively, the field identifier may be spliced by a field name and a field descriptor.
Optionally, after the step 101, the method further includes:
If the byte code file corresponding to the intelligent contract is not the enhanced byte code file, constructing a contract object of the intelligent contract by the virtual machine through the byte code file corresponding to the intelligent contract;
obtaining all fields of the contract object by using a reflection mechanism;
the values of all fields are initialized.
In the embodiment of the application, if the byte code file corresponding to the intelligent contract is not the enhanced byte code file, the byte code file is not included with the enhanced byte code instruction, and the Java virtual machine cannot read the value of the persistence field from the blockchain ledger through the byte code instruction when executing the byte code file subsequently. Based on this, the Java virtual machine needs to read the value of the persistence field from the blockchain ledger in advance. Specifically, the Java virtual machine may invoke a parameterless construction method to construct a contract object of the smart contract based on the bytecode file of the smart contract body class. All fields of the contract object can be obtained through a Java reflection mechanism, default values are given to non-persistent fields in an initialization stage, the values of the persistent fields are read from the blockchain ledger, and the values are given to the persistent fields, so that initialization of all the fields is completed.
And step 103, executing the byte code file corresponding to the intelligent contract by using the virtual machine to finish the response to the call request.
In the embodiment of the application, the Java virtual machine can be used for executing the byte code file corresponding to the intelligent contract. Specifically, the name of the called method and the parameter of the method carried in the call request can be obtained, and the byte code corresponding to the method is executed according to the name of the method and the parameter of the method. And finally, returning an execution result obtained by executing the byte codes corresponding to the method to the user terminal so as to complete the response to the call request.
Optionally, the enhanced bytecode instruction is further configured to read the value of the persistence field in the second state from the memory, for example, the second state is a loaded state, and if one persistence field is in the loaded state, the value of the persistence field is indicated to be loaded into the memory. Based on this, before receiving the call request for calling the smart contract, further comprising:
a1, acquiring a byte code file corresponding to an intelligent contract when a deployment request for deploying the intelligent contract is received;
A2, if the byte code file corresponding to the intelligent contract is an enhanced byte code file, marking the persistence field of the intelligent contract as a second state;
a3, executing the byte code file corresponding to the intelligent contract by using the virtual machine so as to complete the response to the deployment request.
In the embodiment of the application, to realize the calling of the intelligent contract, the deployment of the intelligent contract is required to be completed first. The user can generate a byte code file corresponding to the intelligent contract to be deployed through the user terminal, and send a deployment request to the node equipment, wherein the deployment request is used for deploying the intelligent contract. For example, the deployment request may be carried with a byte code file corresponding to the intelligent contract, and the node device may parse the deployment request to obtain the byte code file. Alternatively, the bytecode file carried by the deployment request may exist in the form of a jar packet.
If the bytecode file corresponding to the smart contract is an enhanced bytecode file, since the value of the persistence field of the smart contract which is not deployed is not stored in the blockchain ledger but is stored in the memory, in order that the Java virtual machine can read the value of the persistence field from the memory by executing the enhanced bytecode instruction later, the persistence field of the smart contract can be marked as a second state, for example, the second state is a loaded state, and if one persistence field is in the loaded state, the value of the persistence field is indicated to be loaded into the memory. Next, a bytecode file corresponding to the smart contract may be executed using the Java virtual machine. Specifically, the byte code file includes a byte code file of a deployment part for deploying the intelligent contract, and the response to the deployment request can be completed by executing the byte code file of the deployment part. Specifically, in the process of executing the byte code file of the deployment part, the method includes the operations of storing the byte code file corresponding to the intelligent contract and the value of the persistence field of the intelligent contract in a blockchain account book, releasing the memory of the contract object by the Java virtual machine, returning the address of the intelligent contract to the user terminal, and the like. It should be understood that the bytecode file of the deployment portion may include an enhanced bytecode instruction for acquiring the value of the persistent field, and when the subsequent Java virtual machine executes the bytecode file of the deployment portion, if the enhanced bytecode instruction is executed, it may be determined whether the persistent field to be acquired is in the second state, if the enhanced bytecode instruction is in the second state, it indicates that the value of the persistent field is already loaded into the memory, and the value of the persistent field may be directly read from the memory.
Optionally, the step A2 specifically includes:
If the byte code file corresponding to the intelligent contract is the enhanced byte code file, constructing a contract object of the intelligent contract by the virtual machine through the byte code file corresponding to the intelligent contract;
obtaining all fields of the contract object by using a reflection mechanism;
initializing the values of all fields;
the persisted field of all fields is marked as a second state.
In the embodiment of the application, if the byte code file corresponding to the intelligent contract is an enhanced byte code file, the Java virtual machine can call a parameter-free construction method to construct the contract object of the intelligent contract based on the byte code file of the intelligent contract main body class. All fields of the contract object may then be obtained through the Java reflection mechanism. All fields of the contract object include persistent fields and non-persistent fields. The Java virtual machine may initially combine the values of all fields of the constraint object, in particular, may assign a default value to all fields, such as assigning a default value of 0 to all fields. Finally, each persistent field may be marked as a second state.
Illustratively, after obtaining all fields of the contract object using the reflection mechanism and initializing values of all fields, all fields of the contract object may be traversed, and for the currently traversed fields, the attributes thereof may be parsed, and whether preset persistence annotations exist in the attributes may be detected. And if the corresponding field traversed currently has the preset persistence annotation, determining the field traversed currently as a persistence field. If the currently traversed field does not have the persistence annotation, the currently traversed field is determined to be a non-persistence field. Optionally, before traversing all the fields, a persistent field state table may be newly built in the memory, if a preset persistent annotation exists in the corresponding field traversed currently, the field traversed currently is identified as a key, the loaded value is inserted into the persistent field state table by using the key value pair as a record, and thus, the marking of the field traversed currently as the loaded state is realized.
Optionally, after the step A1, the method further includes:
If the byte code file corresponding to the intelligent contract is not the enhanced byte code file, constructing a contract object of the intelligent contract by the virtual machine through the byte code file corresponding to the intelligent contract;
obtaining all fields of the contract object by using a reflection mechanism;
initializing the values of all fields;
And executing the byte code file corresponding to the intelligent contract by using the virtual machine to finish the response to the deployment request.
In the embodiment of the application, if the byte code file corresponding to the intelligent contract is not an enhanced byte code file, the Java virtual machine can call a parameter-free construction method to construct a contract object of the intelligent contract based on the byte code file of the intelligent contract main body class; all fields of the contract object may then be obtained through the Java reflection mechanism. The Java virtual machine may initially combine the values of all fields of the constraint object, in particular, may assign all fields a default value for the corresponding data type, such as assigning fields a default 0 value for the corresponding data type. Finally, a Java virtual machine may be used to execute the bytecode file corresponding to the smart contract to complete the response to the deployment request.
Optionally, the manner of generating the enhanced bytecode file includes:
Compiling the intelligent contract to be enhanced to obtain a byte code file to be enhanced corresponding to the intelligent contract to be enhanced;
Adding an enhancement identifier into a constant pool of the byte code file to be enhanced;
Searching a byte code instruction to be replaced in the byte code file to be enhanced after the enhancement identifier is added;
And replacing the byte code instruction to be replaced in the byte code file to be enhanced after the enhancement identification is added with the enhancement byte code instruction, so as to obtain the enhanced byte code file corresponding to the enhanced intelligent contract.
In the embodiment of the application, the user can generate the enhanced byte code file through the user terminal, then carry the generated enhanced byte code file in the form of jar package in the deployment request, and also can directly generate the enhanced byte code file through the node equipment, and the user can select the enhanced byte code file according to the requirement without limitation. The smart contracts to be enhanced, i.e. the smart contracts that the user currently needs to be enhanced. The procedure for generating the enhanced bytecode file is as follows:
Firstly, compiling the intelligent contract to be enhanced by using a plug-in to obtain a byte code file corresponding to the intelligent contract to be enhanced, and marking the byte code file as the byte code file to be enhanced.
The plug-in may then analyze the byte code files to be enhanced to identify byte code files of the smart contract body class of the smart contract to be enhanced. For the byte code file of the intelligent contract main body class, the size s of the constant pool of the byte code file can be modified to s+1, and an enhancement identifier is added to the constant pool, for example, a preset enhancement constant item is inserted into the end item of the constant pool.
The field table of the byte code file may then be read, resolving the attributes of each field in the field table. If the attribute of the field contains the preset persistence annotation, the field name and the descriptor of the field are spliced to obtain the field identification of the field, and the field identification is stored in a persistence field identification list.
And finally, a method table of the byte Code file can be read, and Java virtual machine instructions executed by the method are stored in the Code attribute of each method in the method table. For any one of the methods in the method table except the construction method, the following operations are performed:
And traversing each Java virtual machine instruction in the Code attribute of the method, and if the currently traversed Java virtual machine instruction is a byte Code instruction to be replaced, replacing the byte Code instruction to be replaced with an enhanced byte Code instruction to obtain an enhanced byte Code file corresponding to the enhanced intelligent contract. By way of example, the bytecode instruction to be replaced may be an instruction in a virtual machine instruction set of a Java virtual machine, such as a getfield instruction and getstatic instruction. The byte code to be replaced instruction is to obtain a value of a persistence field of the smart contract. It should be noted that, for each getfield instruction and getstatic instruction, a field item index (as shown in fig. 2) follows, according to the field item index, a field name and a field descriptor may be obtained, and a field identifier may be obtained by splicing the field name and the field descriptor, where the field identifier points to, that is, a field that needs to be obtained by the getfield instruction or the getstatic instruction. If the field identification exists in the persisted field identification list, then the field that the getfield instruction or getstatic instruction needs to fetch may be determined to be a persisted field, i.e., the getfield instruction or getstatic instruction is a byte code instruction to be replaced.
When executing the enhanced byte code instruction, the Java virtual machine can realize the following flow:
(1) The field entry index in the enhanced bytecode instruction is read, and the symbol reference of the field is obtained from the constant pool through the field entry index.
(2) And obtaining a field name and a field descriptor through the symbol reference of the field, and splicing the field name and the field descriptor to obtain a field identifier. And searching the field identifier in the persistent field state table to obtain a value (i.e. loaded or unloaded) corresponding to the field identifier.
(3) If the value corresponding to the field identifier is loaded, that is, the field pointed to by the field identifier is in the loaded state (that is, the second state), at this time, the value of the field can be directly read from the memory.
(4) If the corresponding value of the field identifier is not loaded, namely the field pointed by the field identifier is in an unloaded state (namely a first state), at the moment, the value of the field can be read from the blockchain ledger through the address and the field name of the intelligent contract, and the field is marked as the loaded state.
From the above, in the present application, a call request for calling an intelligent contract is received, first, a byte code file corresponding to the intelligent contract is obtained, if the byte code file corresponding to the intelligent contract is an enhanced byte code file, a first preprocessing is performed on a persistence field of the intelligent contract, the persistence field is a field with a corresponding value stored in a blockchain ledger, the enhanced byte code file is a byte code file containing an enhanced byte code instruction, the enhanced byte code instruction is used for reading a value of the persistence field after the first preprocessing from the blockchain ledger, and finally, a virtual machine is used to execute the byte code file corresponding to the intelligent contract to complete the call. The scheme of the application utilizes byte code enhancement to enhance the byte code instructions in the byte code files corresponding to the intelligent contracts, and can enable the Java virtual machine to read the values of the persistence fields of the intelligent contracts from the blockchain account book through the single enhanced byte code instructions. Meanwhile, the Java virtual machine does not load the value of the persistence field into the memory when loading the byte code file, but reads the value of the persistence field from the blockchain ledger to the memory when executing the enhanced byte code instruction, thereby realizing lazy loading of the persistence field, reducing memory overhead and improving execution efficiency.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
Fig. 3 is a block diagram of an intelligent contract executing apparatus according to an embodiment of the present application, and only a portion related to the embodiment of the present application is shown for convenience of explanation.
The smart contract execution apparatus 300 includes:
An obtaining unit 301, configured to receive a call request for calling an intelligent contract, and obtain a byte code file corresponding to the intelligent contract;
A processing unit 302, configured to, if a bytecode file corresponding to the smart contract is an enhanced bytecode file, mark a persistence field of the smart contract as a first state, where the persistence field is a field in which a corresponding value is stored in a blockchain ledger, and the enhanced bytecode file is a bytecode file including an enhanced bytecode instruction, where the enhanced bytecode instruction is configured to read a value of the persistence field in the first state from the blockchain ledger;
And the executing unit 303 is configured to execute the byte code file corresponding to the intelligent contract by using the virtual machine to complete the response to the call request.
Optionally, the smart contract execution apparatus 300 further includes:
the detection unit is used for detecting whether a constant pool of the byte code file corresponding to the intelligent contract contains an enhancement identifier or not;
and the determining unit is used for determining that the byte code file corresponding to the intelligent contract is the enhanced byte code file if the constant pool contains the enhanced identifier.
Optionally, the processing unit 302 includes:
An object construction subunit, configured to construct, by the virtual machine, a contract object of the intelligent contract through the byte code file corresponding to the intelligent contract if the byte code file corresponding to the intelligent contract is an enhanced byte code file;
A field obtaining subunit, configured to obtain all the fields of the contract object by using a reflection mechanism;
an initializing subunit, configured to initialize values of non-persistent fields in all fields, where the non-persistent fields are fields in all fields except for the persistent fields;
and the first marking subunit is used for marking the persistent fields in all the fields as a first state.
Optionally, the smart contract execution apparatus 300 further includes:
The traversal determining unit is used for traversing all the fields, and if the currently traversed fields correspondingly have preset persistence notes, the currently traversed fields are determined to be persistence fields.
Optionally, the smart contract execution apparatus 300 further includes:
A file obtaining unit, configured to obtain a byte code file corresponding to the intelligent contract when receiving a deployment request for deploying the intelligent contract;
A second marking unit, configured to mark a persistence field of the smart contract as a second state if the byte code file corresponding to the smart contract is the enhanced byte code file;
and the file executing unit is used for executing the byte code file corresponding to the intelligent contract by using the virtual machine so as to complete the response to the deployment request.
Optionally, the second marking unit includes:
A contract object construction subunit, configured to construct, by the virtual machine, a contract object of the intelligent contract according to the byte code file corresponding to the intelligent contract if the byte code file corresponding to the intelligent contract is an enhanced byte code file;
A contract field obtaining subunit, configured to obtain all fields of the contract object by using a reflection mechanism;
initializing the values of all fields;
A second state marking subunit configured to mark the persistent field in all the fields as a second state.
Optionally, the method for generating the enhanced byte code file includes:
compiling the intelligent contract to be enhanced to obtain a byte code file to be enhanced corresponding to the intelligent contract to be enhanced;
Adding an enhancement identifier into the constant pool of the byte code file to be enhanced;
Searching a byte code to be replaced in the byte code file to be enhanced after the enhancement identification is added, wherein the byte code to be replaced is an instruction in a virtual machine instruction set of the virtual machine, and the byte code to be replaced is used for acquiring the value of a persistence field of the intelligent contract;
And replacing the byte code instruction to be replaced in the byte code file to be enhanced after the enhancement identification is added with the enhancement byte code instruction, so as to obtain the enhanced byte code file corresponding to the enhanced intelligent contract.
From the above, in the present application, a call request for calling an intelligent contract is received, first, a byte code file corresponding to the intelligent contract is obtained, if the byte code file corresponding to the intelligent contract is an enhanced byte code file, a first preprocessing is performed on a persistence field of the intelligent contract, the persistence field is a field with a corresponding value stored in a blockchain ledger, the enhanced byte code file is a byte code file containing an enhanced byte code instruction, the enhanced byte code instruction is used for reading a value of the persistence field after the first preprocessing from the blockchain ledger, and finally, a virtual machine is used to execute the byte code file corresponding to the intelligent contract to complete the call. The scheme of the application utilizes byte code enhancement to enhance the byte code instructions in the byte code files corresponding to the intelligent contracts, and can enable the Java virtual machine to read the values of the persistence fields of the intelligent contracts from the blockchain account book through the single enhanced byte code instructions. Meanwhile, the Java virtual machine does not load the value of the persistence field into the memory when loading the byte code file, but reads the value of the persistence field from the blockchain ledger to the memory when executing the enhanced byte code instruction, thereby realizing lazy loading of the persistence field, reducing memory overhead and improving execution efficiency.
Fig. 4 is a schematic structural diagram of a node device according to an embodiment of the present application, where the node device may be a server, a desktop computer or a tablet computer, which is not limited herein. As shown in fig. 4, the node apparatus 4 of this embodiment includes: at least one processor 40 (only one is shown in fig. 4), a memory 41 and a computer program 42 stored in the memory 41 and executable on the at least one processor 40, the processor 40 implementing the following steps when executing the computer program 42:
Receiving a calling request for calling the intelligent contract, and acquiring a byte code file corresponding to the intelligent contract;
if the byte code file corresponding to the intelligent contract is an enhanced byte code file, marking a persistence field of the intelligent contract as a first state, wherein the persistence field is a field of which a corresponding value is stored in a blockchain ledger, the enhanced byte code file is a byte code file containing enhanced byte code instructions, and the enhanced byte code instructions are used for reading the value of the persistence field in the first state from the blockchain ledger;
and executing the byte code file corresponding to the intelligent contract by using the virtual machine to finish the response to the call request.
In a second possible implementation provided by the first possible implementation, assuming that the foregoing is the first possible implementation, after the acquiring the bytecode file corresponding to the smart contract, the following steps are further implemented when the processor 40 executes the computer program 42:
detecting whether a constant pool of the byte code file corresponding to the intelligent contract contains an enhancement identifier or not;
and if the constant pool contains the enhancement identifier, determining the byte code file corresponding to the intelligent contract as the enhancement byte code file.
In a third possible implementation manner provided by the first possible implementation manner, if the bytecode file corresponding to the smart contract is an enhanced bytecode file, marking a persistence field of the smart contract as a first state includes:
If the byte code file corresponding to the intelligent contract is an enhanced byte code file, the virtual machine constructs a contract object of the intelligent contract through the byte code file corresponding to the intelligent contract;
Obtaining all fields of the contract object by using a reflection mechanism;
Initializing values of non-persistent fields in all fields, wherein the non-persistent fields are fields except for the persistent fields in all fields;
The persisted field in all fields is marked as a first state.
In a fourth possible implementation provided by the third possible implementation as a basis, after the obtaining all fields of the contract object using a reflection mechanism, the following steps are further implemented when the processor 40 executes the computer program 42:
And traversing all the fields, and if the corresponding field traversed currently has a preset persistence annotation, determining the field traversed currently as a persistence field.
In a fifth possible implementation provided by the first possible implementation, the enhanced bytecode instruction is further configured to read, from a memory, a value of a persistence field in a second state, and the processor 40 further performs the following steps when executing the computer program 42 before receiving the call request for invoking the smart contract:
When a deployment request for deploying the intelligent contract is received, acquiring a byte code file corresponding to the intelligent contract;
if the byte code file corresponding to the intelligent contract is the enhanced byte code file, marking the persistence field of the intelligent contract as a second state;
And executing the byte code file corresponding to the intelligent contract by using the virtual machine so as to complete the response to the deployment request.
In a sixth possible implementation manner provided by the fifth possible implementation manner, the marking the persistence field of the smart contract as the second state if the bytecode file corresponding to the smart contract is the enhanced bytecode file includes:
If the byte code file corresponding to the intelligent contract is an enhanced byte code file, the virtual machine constructs a contract object of the intelligent contract through the byte code file corresponding to the intelligent contract;
Obtaining all fields of the contract object by using a reflection mechanism;
initializing the values of all fields;
the persisted field of all fields is marked as a second state.
In a seventh possible implementation provided on the basis of the first possible implementation, or the second possible implementation, or the third possible implementation, or the fourth possible implementation, or the fifth possible implementation, or the sixth possible implementation, the manner of generating the enhanced bytecode file includes:
compiling the intelligent contract to be enhanced to obtain a byte code file to be enhanced corresponding to the intelligent contract to be enhanced;
Adding an enhancement identifier into the constant pool of the byte code file to be enhanced;
Searching a byte code to be replaced in the byte code file to be enhanced after the enhancement identification is added, wherein the byte code to be replaced is an instruction in a virtual machine instruction set of the virtual machine, and the byte code to be replaced is used for acquiring the value of a persistence field of the intelligent contract;
And replacing the byte code instruction to be replaced in the byte code file to be enhanced after the enhancement identification is added with the enhancement byte code instruction, so as to obtain the enhanced byte code file corresponding to the enhanced intelligent contract.
The node device 4 may be a computing device such as a server. The node device may include, but is not limited to, a processor 40, a memory 41. It will be appreciated by those skilled in the art that fig. 4 is merely an example of node device 4 and is not meant to be limiting of node device 4, and may include more or fewer components than shown, or may combine certain components, or may include different components, such as input-output devices, network access devices, etc.
The Processor 40 may be a central processing unit (Central Processing Unit, CPU), the Processor 40 may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL processors, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), off-the-shelf Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 41 may in some embodiments be an internal storage unit of the node device 4, such as a hard disk or a memory of the node device 4. The memory 41 may also be an external storage device of the node device 4 in other embodiments, for example, a plug-in hard disk, a smart memory card (SMART MEDIA CARD, SMC), a Secure Digital (SD) card, a flash memory card (FLASH CARD) or the like, which are provided on the node device 4. Further, the memory 41 may include both the internal storage unit and the external storage device of the node device 4. The memory 41 is used for storing an operating system, an application program, a boot loader (BootLoader), data, other programs, and the like, such as program codes of the computer programs. The above-described memory 41 may also be used to temporarily store data that has been output or is to be output.
From the above, in the present application, a call request for calling an intelligent contract is received, first, a byte code file corresponding to the intelligent contract is obtained, if the byte code file corresponding to the intelligent contract is an enhanced byte code file, a first preprocessing is performed on a persistence field of the intelligent contract, the persistence field is a field with a corresponding value stored in a blockchain ledger, the enhanced byte code file is a byte code file containing an enhanced byte code instruction, the enhanced byte code instruction is used for reading a value of the persistence field after the first preprocessing from the blockchain ledger, and finally, a virtual machine is used to execute the byte code file corresponding to the intelligent contract to complete the call. The scheme of the application utilizes byte code enhancement to enhance the byte code instructions in the byte code files corresponding to the intelligent contracts, and can enable the Java virtual machine to read the values of the persistence fields of the intelligent contracts from the blockchain account book through the single enhanced byte code instructions. Meanwhile, the Java virtual machine does not load the value of the persistence field into the memory when loading the byte code file, but reads the value of the persistence field from the blockchain ledger to the memory when executing the enhanced byte code instruction, thereby realizing lazy loading of the persistence field, reducing memory overhead and improving execution efficiency.
It should be noted that, because the content of information interaction and execution process between the above devices/units is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and will not be described herein.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The embodiments of the present application also provide a computer readable storage medium storing a computer program which, when executed by a processor, implements the steps of the respective method embodiments described above.
The integrated units described above, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiment, and may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, where the computer program, when executed by a processor, may implement the steps of each of the method embodiments described above. The computer program comprises computer program code, and the computer program code can be in a source code form, an object code form, an executable file or some intermediate form and the like. The computer readable medium may include at least: any entity or device capable of carrying the computer program code to the node apparatus, a recording medium, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, and a software distribution medium. Such as a U-disk, removable hard disk, magnetic or optical disk, etc. In some jurisdictions, computer readable media may not be electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/network device and method may be implemented in other manners. For example, the apparatus/network device embodiments described above are merely illustrative, e.g., the division of modules or elements described above is merely a logical functional division, and there may be additional divisions in actual implementation, e.g., multiple elements or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described above as separate components may or may not be physically separate, and components shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.
Claims (9)
1. A method of executing a smart contract, comprising:
receiving a calling request for calling an intelligent contract, and acquiring a byte code file corresponding to the intelligent contract;
If the byte code file corresponding to the intelligent contract is an enhanced byte code file, marking a persistence field of the intelligent contract as a first state, wherein the first state is an unloaded state, the persistence field is a field of which a corresponding value is stored in a blockchain ledger, the enhanced byte code file is a byte code file containing an enhanced byte code instruction, and the enhanced byte code instruction is used for reading the value of the persistence field in the first state from the blockchain ledger;
Executing a byte code file corresponding to the intelligent contract by using a JAVA virtual machine to complete the response to the call request;
The way of generating the enhanced bytecode file includes:
Compiling an intelligent contract to be enhanced to obtain a byte code file to be enhanced corresponding to the intelligent contract to be enhanced;
Adding an enhancement identifier into the constant pool of the byte code file to be enhanced;
Searching a byte code instruction to be replaced in the byte code file to be enhanced after the enhancement identifier is added, wherein the byte code instruction to be replaced is an instruction in a virtual machine instruction set of the JAVA virtual machine, and the byte code instruction to be replaced is used for acquiring the value of the persistence field of the intelligent contract;
and replacing the byte code instruction to be replaced in the byte code file to be enhanced after the enhancement identification is added with the enhancement byte code instruction to obtain the enhanced byte code file corresponding to the enhanced intelligent contract.
2. The smart contract execution method according to claim 1, further comprising, after the acquiring the bytecode file corresponding to the smart contract:
Detecting whether a constant pool of the byte code file corresponding to the intelligent contract contains an enhancement identifier or not;
and if the constant pool contains the enhancement identifier, determining the byte code file corresponding to the intelligent contract as the enhancement byte code file.
3. The method for executing the smart contract according to claim 1, wherein if the bytecode file corresponding to the smart contract is an enhanced bytecode file, marking the persistence field of the smart contract as a first state includes:
if the byte code file corresponding to the intelligent contract is an enhanced byte code file, constructing a contract object of the intelligent contract by the JAVA virtual machine through the byte code file corresponding to the intelligent contract;
Obtaining all fields of the contract object by using a reflection mechanism;
initializing values of non-persistent fields in all fields, wherein the non-persistent fields are fields except for the persistent fields in all fields;
The persisted field in all fields is marked as a first state.
4. The smart contract execution method of claim 3, further comprising, after the obtaining all fields of the contract object using a reflection mechanism:
Traversing all fields;
and if the corresponding field traversed currently has the preset persistence annotation, determining the field traversed currently as a persistence field.
5. The smart contract execution method of claim 1, wherein the enhanced bytecode instruction is further configured to read a value of a persistence field in a second state from a memory, the smart contract execution method further comprising, prior to the receiving the call request to invoke the smart contract:
when a deployment request for deploying the intelligent contract is received, acquiring a byte code file corresponding to the intelligent contract;
If the byte code file corresponding to the intelligent contract is the enhanced byte code file, marking the persistence field of the intelligent contract as a second state;
and executing the byte code file corresponding to the intelligent contract by using the JAVA virtual machine so as to complete the response to the deployment request.
6. The method for executing the smart contract according to claim 5, wherein, if the bytecode file corresponding to the smart contract is the enhanced bytecode file, marking the persistence field of the smart contract as the second state includes:
if the byte code file corresponding to the intelligent contract is an enhanced byte code file, constructing a contract object of the intelligent contract by the JAVA virtual machine through the byte code file corresponding to the intelligent contract;
Obtaining all fields of the contract object by using a reflection mechanism;
initializing the values of all fields;
the persisted field of all fields is marked as a second state.
7. An intelligent contract execution apparatus, comprising:
the intelligent contract acquiring unit is used for receiving a calling request for calling the intelligent contract and acquiring a byte code file corresponding to the intelligent contract;
The processing unit is used for marking a persistence field of the intelligent contract as a first state if the byte code file corresponding to the intelligent contract is an enhanced byte code file, wherein the first state is an unloaded state, the persistence field is a field of which a corresponding value is stored in a blockchain ledger, the enhanced byte code file is a byte code file containing an enhanced byte code instruction, and the enhanced byte code instruction is used for reading the value of the persistence field in the first state from the blockchain ledger;
the execution unit is used for executing the byte code file corresponding to the intelligent contract by using the JAVA virtual machine so as to complete the response to the call request;
The way of generating the enhanced bytecode file includes:
Compiling an intelligent contract to be enhanced to obtain a byte code file to be enhanced corresponding to the intelligent contract to be enhanced;
Adding an enhancement identifier into the constant pool of the byte code file to be enhanced;
Searching a byte code instruction to be replaced in the byte code file to be enhanced after the enhancement identifier is added, wherein the byte code instruction to be replaced is an instruction in a virtual machine instruction set of the JAVA virtual machine, and the byte code instruction to be replaced is used for acquiring the value of the persistence field of the intelligent contract;
and replacing the byte code instruction to be replaced in the byte code file to be enhanced after the enhancement identification is added with the enhancement byte code instruction to obtain the enhanced byte code file corresponding to the enhanced intelligent contract.
8. A node device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 6 when executing the computer program.
9. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011395356.1A CN112765676B (en) | 2020-12-03 | 2020-12-03 | Intelligent contract executing method, intelligent contract executing device and node equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011395356.1A CN112765676B (en) | 2020-12-03 | 2020-12-03 | Intelligent contract executing method, intelligent contract executing device and node equipment |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112765676A CN112765676A (en) | 2021-05-07 |
CN112765676B true CN112765676B (en) | 2024-07-12 |
Family
ID=75693250
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011395356.1A Active CN112765676B (en) | 2020-12-03 | 2020-12-03 | Intelligent contract executing method, intelligent contract executing device and node equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112765676B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114297177B (en) * | 2021-12-23 | 2025-07-15 | 蚂蚁区块链科技(上海)有限公司 | A method, device, equipment and system for obtaining off-chain data |
CN114356604B (en) * | 2021-12-31 | 2025-05-06 | 杭州趣链科技有限公司 | Contract calling method, device, electronic device and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109710384A (en) * | 2018-12-29 | 2019-05-03 | 杭州趣链科技有限公司 | A kind of safe Java intelligence contract explanation enforcement engine and method |
CN110046991A (en) * | 2018-12-12 | 2019-07-23 | 阿里巴巴集团控股有限公司 | A kind of data processing method and system based on block chain intelligence contract |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107392619B (en) * | 2017-07-31 | 2020-12-29 | 众安信息技术服务有限公司 | Smart contract processing method and device |
SG11201908890XA (en) * | 2019-03-26 | 2019-10-30 | Alibaba Group Holding Ltd | System and method for implementing different types of blockchain contracts |
CN111563237B (en) * | 2020-03-24 | 2023-08-08 | 博雅正链(北京)科技有限公司 | Intelligent contract security enhancement method |
CN111770202B (en) * | 2020-08-31 | 2021-10-29 | 支付宝(杭州)信息技术有限公司 | Method for executing intelligent contract, block chain node and storage medium |
-
2020
- 2020-12-03 CN CN202011395356.1A patent/CN112765676B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110046991A (en) * | 2018-12-12 | 2019-07-23 | 阿里巴巴集团控股有限公司 | A kind of data processing method and system based on block chain intelligence contract |
CN109710384A (en) * | 2018-12-29 | 2019-05-03 | 杭州趣链科技有限公司 | A kind of safe Java intelligence contract explanation enforcement engine and method |
Also Published As
Publication number | Publication date |
---|---|
CN112765676A (en) | 2021-05-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110162296B (en) | Method and device for generating application programming interface document and terminal equipment | |
CN109976761B (en) | Software development kit generation method and device and terminal equipment | |
US6880155B2 (en) | Token-based linking | |
JP4913302B2 (en) | Language subset validation | |
US10564943B2 (en) | Special calling sequence for caller-sensitive methods | |
CN111381938B (en) | Method and system for executing intelligent contracts in block chain based on basic instruction set | |
US10417024B2 (en) | Generating verification metadata and verifying a runtime type based on verification metadata | |
US8818967B2 (en) | Method for compressing identifiers | |
CN112765676B (en) | Intelligent contract executing method, intelligent contract executing device and node equipment | |
CN112631649B (en) | Smart contract management method, device, terminal equipment and medium | |
CN113961919A (en) | Malicious software detection method and device | |
US8805801B2 (en) | Method for compressing a .net file | |
CN111625225A (en) | Program specified data output method and device | |
US20100180269A1 (en) | Domains with polymorphic type implementations | |
US20240192936A1 (en) | Systems and methods for creating an extended smart card application file from multiple smart card application files | |
CN117873483A (en) | Method and device for compiling intelligent contract, electronic equipment and storage medium | |
CN116700840B (en) | File execution method, device, electronic equipment and readable storage medium | |
CN117056906B (en) | Instruction access control method, system, storage medium and equipment | |
EP4386542A1 (en) | A method for the relink of software components installed on a device being updated | |
CN111045657A (en) | Operating method and operating device of program code, and compiling method and compiling device | |
CN116257282A (en) | Application program updating method and device, storage medium and computer equipment | |
CN116010100A (en) | Contract calling method, device, equipment and storage medium in block chain system | |
HK40032832A (en) | Method and system for executing intelligent contract in blockchain based on basic instruction set | |
HK40032832B (en) | Method and system for executing intelligent contract in blockchain based on basic instruction set |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |