CN114201176A - Intelligent contract compiling and matching method, device, equipment and storage medium - Google Patents

Intelligent contract compiling and matching method, device, equipment and storage medium Download PDF

Info

Publication number
CN114201176A
CN114201176A CN202111538095.9A CN202111538095A CN114201176A CN 114201176 A CN114201176 A CN 114201176A CN 202111538095 A CN202111538095 A CN 202111538095A CN 114201176 A CN114201176 A CN 114201176A
Authority
CN
China
Prior art keywords
compiler
contract
data
compiling
preprocessed
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.)
Pending
Application number
CN202111538095.9A
Other languages
Chinese (zh)
Inventor
郑子彬
杨杰宇
郑沛霖
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sun Yat Sen University
Original Assignee
Sun Yat Sen University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sun Yat Sen University filed Critical Sun Yat Sen University
Priority to CN202111538095.9A priority Critical patent/CN114201176A/en
Publication of CN114201176A publication Critical patent/CN114201176A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Abstract

The invention discloses an intelligent contract compiling and matching method, device, equipment and storage medium, wherein the method comprises the following steps: acquiring intelligent contract data and compiler data from an Ethernet system according to a preset acquisition period; carrying out contract data preprocessing on the intelligent contract data to obtain preprocessed contract data; performing compiler data preprocessing on the compiler data to obtain a plurality of preprocessed compiler data; matching the plurality of pre-processing compiler data according to the pre-processing contract data, and determining a target compiler based on a matching result; the target compiler is combined with the preprocessed contract data to compile the contract to obtain a compiling result, so that the intelligent contract is efficiently compiled in an automatic compiler screening mode on the basis of ensuring low cost.

Description

Intelligent contract compiling and matching method, device, equipment and storage medium
Technical Field
The invention relates to the technical field of intelligent contract compilation, in particular to an intelligent contract compilation matching method, device, equipment and storage medium.
Background
The block chain is a decentralized accounting technology, and plays a great role in various application scenes by virtue of characteristics of decentralized, privacy protection, difficult tampering and the like. With the development of technology, representative blockchain platforms such as etherhouse and superhedger Fabric are coming out in succession, and they also represent the explosion in the field of blockchain technology.
On the block chain of the ether house, the intelligent contract function is realized by deploying intelligent contract byte codes, and because the transaction records of the ether house have non-tamper property, the intelligent contract deployed on the ether house can not be tampered, and the application function is permanently effective once deployed on the contract.
However, in the current scheme for compiling the intelligent contracts in the etherhouses, a compiler corresponding to a certain contract is manually screened, and after the compiled content is obtained, the content needs to be processed. However, the intelligent contracts on the current ether houses have less public available information, most contracts only have source codes and binary files, the number of the intelligent contracts is large, the versions of compilers are large, different compilers of the same intelligent contract can generate different results, and the cost for manually screening and compiling one by one is high.
Disclosure of Invention
The invention provides an intelligent contract compiling and matching method, device, equipment and storage medium, which solve the technical problem that the existing intelligent contract compiling scheme of an Ethengfang is difficult to realize intelligent contract compiling with low cost and high efficiency because a compiler can only be manually screened.
The invention provides an intelligent contract compiling and matching method in a first aspect, which comprises the following steps:
acquiring intelligent contract data and compiler data from an Ethernet system according to a preset acquisition period;
carrying out contract data preprocessing on the intelligent contract data to obtain preprocessed contract data;
performing compiler data preprocessing on the compiler data to obtain a plurality of preprocessed compiler data;
matching the plurality of preprocessed compiler data according to the preprocessed contract data, and determining a target compiler based on a matching result;
and compiling the contract by combining the target compiler with the preprocessed contract data to obtain a compiling result.
Optionally, the step of preprocessing the intelligent contract data to obtain preprocessed contract data includes:
retrieving the intelligent contract data according to a preset contract key value, and determining a corresponding contract address, a contract source code, a contract byte code, a compiling optimization mark and a contract compiler name;
calculating a byte code hash value corresponding to the contract byte code by adopting an SHA256 algorithm;
dividing the compiler name according to a preset digit to obtain a corresponding contract compiler hash number and a contract compiler version number;
and constructing preprocessed contract data by adopting the contract address, the contract source code, the contract byte code, the byte code hash value, the compiling optimization mark, the contract compiler version number and the contract compiler hash number.
Optionally, the step of performing compiler data preprocessing on the compiler data to obtain a plurality of preprocessed compiler data includes:
retrieving the compiler data according to a preset compiler key value, and determining a plurality of corresponding compiler full names;
intercepting the full name of each compiler according to a preset digit to obtain a plurality of corresponding hash numbers of the compiler and a plurality of version numbers of the compiler;
storing the compiler which is fully associated with each compiler, and recording the storage address of the corresponding compiler;
and constructing a plurality of preprocessed compiler data by adopting the full name of the compiler, the version number of the compiler, the Hash number of the compiler and the storage address of the compiler.
Optionally, the step of matching the plurality of preprocessed compiler data according to the preprocessed contract data and determining a target compiler based on the matching result includes:
matching a plurality of compiler hash numbers according to the contract compiler hash number, and judging whether a target compiler hash number identical to the contract compiler hash number exists or not;
and if so, acquiring the target compiler from the compiler storage address corresponding to the hash number of the target compiler.
Optionally, the method further comprises:
if not, matching a plurality of compiler version numbers according to the contract compiler version number, and judging whether a target compiler version number identical to the contract compiler version number exists;
if so, acquiring a target compiler from a compiler storage address corresponding to the target compiler version number;
and if not, generating missing related compiler information and uploading the missing related compiler information to a log component in the Etherhouse system.
Optionally, the compilation result comprises a first compilation result and a second compilation result; the step of compiling the contract by combining the target compiler with the preprocessed contract data to obtain a compilation result includes:
if the compiling optimization mark is a first preset mark, executing first compiling on the contract source code through the target compiler to obtain a first compiling result;
and if the compiling optimization mark is a second preset mark, executing second compiling on the contract source code through the target compiler to obtain a second compiling result.
Optionally, the method further comprises:
extracting a compilation contract bytecode in the compilation result;
calculating a compiled byte code hash value corresponding to the compiled contract byte code by adopting an SHA256 algorithm;
judging whether the compiled byte code hash value is the same as the byte code hash value;
if yes, generating a compiling success prompt;
and if not, generating a compiling abnormity prompt and uploading the compiling abnormity prompt to a log component in the Ethernet workshop system.
The second aspect of the present invention provides an intelligent contract compiling and matching apparatus, including:
the data acquisition module is used for acquiring intelligent contract data and compiler data from the Ethernet workshop system according to a preset acquisition cycle;
the contract data preprocessing module is used for preprocessing the intelligent contract data to obtain preprocessed contract data;
the compiler data preprocessing module is used for performing compiler data preprocessing on the compiler data to obtain a plurality of preprocessed compiler data;
a target compiler selection module, configured to match the plurality of preprocessed compiler data according to the preprocessed contract data, and determine a target compiler based on a matching result;
and the compiling module is used for compiling the contract by combining the target compiler with the preprocessed contract data to obtain a compiling result.
A third aspect of the present invention provides an electronic device, including a memory and a processor, where the memory stores a computer program, and the computer program, when executed by the processor, causes the processor to execute the steps of the intelligent contract compiling and matching method according to any one of the first aspect of the present invention.
A fourth aspect of the present invention provides a computer readable storage medium having stored thereon a computer program which, when executed, implements the intelligent contract compilation matching method of any one of the first aspects of the present invention.
According to the technical scheme, the invention has the following advantages:
the method comprises the steps of obtaining intelligent contract data and compiler data from an Ethernet system according to a preset obtaining period; respectively carrying out contract data preprocessing on the intelligent contract data and compiler data preprocessing on the compiler data to obtain preprocessed contract data and a plurality of preprocessed compiler data; matching compiler hash numbers corresponding to the plurality of preprocessed compiler data according to the contract compiler hash numbers in the preprocessed contract data, and acquiring a target compiler from a compiler storage address based on a matching result; and finally, carrying out corresponding contract compilation by combining the compilation optimization marks in the preprocessed contract data through the target compiler to obtain a compilation result corresponding to the intelligent contract data. Therefore, the technical problem that the existing Ether house intelligent contract compiling scheme is difficult to realize low-cost and efficient intelligent contract compiling because the compiler can only be manually screened is solved, and then the intelligent contract compiling is efficiently carried out in an automatic compiler screening mode on the basis of ensuring low cost.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without inventive exercise.
FIG. 1 is a flowchart illustrating steps of an intelligent contract compiling and matching method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating steps of a method for matching intelligent contract compilation according to a second embodiment of the present invention;
FIG. 3 is a diagram illustrating a structure of pre-processing contract data according to an embodiment of the present invention;
FIG. 4 is a block diagram of a pre-processing compiler data according to an embodiment of the present invention;
fig. 5 is a block diagram of an intelligent contract compiling and matching apparatus according to a third embodiment of the present invention.
Detailed Description
The embodiment of the invention provides an intelligent contract compiling and matching method, device, equipment and storage medium, which are used for solving the technical problem that the existing Ethengfang intelligent contract compiling scheme is difficult to realize low-cost and high-efficiency intelligent contract compiling because a compiler can only be manually screened.
An etherhouse refers to an open software platform based on blockchain technology, and the etherhouse network not only records transaction history, but also allows developers to build and deploy decentralized applications on the etherhouse. The difference between the decentralized application program and the traditional application program is that the decentralized application program can realize the application function without depending on a certain central platform, and the decentralized application program is realized by depending on an intelligent contract.
The term "smart contracts" initially refers to the automation of general legal contracts. In embodiments of the present invention, smart contracts refer to code scripts running on a blockchain that allow trusted transactions to be conducted without a third party, which transactions are traceable and irreversible. On the ether house, the intelligent contract function is realized by deploying the intelligent contract byte codes, and because the transaction records of the ether house have non-tamper property, the intelligent contract deployed on the ether house can not be tampered, and the application function is permanently effective once deployed on the contract.
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the embodiments described below are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, fig. 1 is a flowchart illustrating steps of an intelligent contract compiling and matching method according to an embodiment of the present invention.
The invention provides an intelligent contract compiling and matching method, which comprises the following steps:
step 101, acquiring intelligent contract data and compiler data from an Ethernet workshop system according to a preset acquisition cycle;
because only intelligent contract byte codes are deployed on the current Ethernet workshop, when a certain contract transaction is abnormal, enough information is lacked for positioning errors, the Ethernet workshop platform does not have mapping information of the byte codes and the contract source codes, if a mapping relation needs to be obtained, the contract needs to be recompiled, and relevant information is obtained from a compiling result and processed.
Therefore, in the embodiment of the present invention, the latest issued intelligent contract data and compiler data may be acquired from the ethernet system according to a preset acquisition period by setting a timing task, so as to acquire a data basis for subsequent processing.
It should be noted that, in order to save resources, the obtaining period may be set to be one day, one hour, or the like, and the specific period is not limited in this embodiment of the present invention.
102, preprocessing the intelligent contract data to obtain preprocessed contract data;
in the embodiment of the present invention, since the obtained intelligent contract data is usually page data in an HTML format, the intelligent contract data may be preprocessed to extract corresponding preprocessed contract data, such as a contract source code, a contract bytecode, a compilation optimization flag, a contract compiler version number, a contract compiler hash number, and the like.
103, performing compiler data preprocessing on the compiler data to obtain a plurality of preprocessed compiler data;
meanwhile, the obtained compiler data also comprises related HTML file data besides the compiler body, so that the compiler data can be preprocessed to extract preprocessed compiler data such as the full name of the compiler, the version number of the compiler, the hash number of the compiler, the storage address of the compiler and the like corresponding to each compiler.
104, matching a plurality of pre-processing compiler data according to the pre-processing contract data, and determining a target compiler based on a matching result;
in a specific implementation, the compiler hash numbers in the plurality of preprocessed compiler data may be matched according to the contract compiler hash numbers in the preprocessed contract data as a matching target, so as to determine a target compiler hash number corresponding to the contract compiler hash number.
And after the hash number of the target compiler is determined, acquiring the corresponding target compiler from the storage address of the compiler associated with the hash number.
And 105, carrying out contract compiling by combining the preprocessed contract data through the target compiler to obtain a compiling result.
After the target compiler is determined, the target compiler can be adopted to combine with the compiling optimization marks in the preprocessed contract data, and the compiling source code is compiled by selecting a corresponding compiling mode according to the compiling optimization marks, so that a compiling result corresponding to the intelligent contract data is obtained.
In the embodiment of the invention, intelligent contract data and compiler data are acquired from an Ethernet system according to a preset acquisition cycle; respectively carrying out contract data preprocessing on the intelligent contract data and compiler data preprocessing on the compiler data to obtain preprocessed contract data and a plurality of preprocessed compiler data; matching compiler hash numbers corresponding to the plurality of preprocessed compiler data according to the contract compiler hash numbers in the preprocessed contract data, and acquiring a target compiler from a compiler storage address based on a matching result; and finally, carrying out corresponding contract compilation by combining the compilation optimization marks in the preprocessed contract data through the target compiler to obtain a compilation result corresponding to the intelligent contract data. Therefore, the technical problem that the existing Ether house intelligent contract compiling scheme is difficult to realize low-cost and efficient intelligent contract compiling because the compiler can only be manually screened is solved, and then the intelligent contract compiling is efficiently carried out in an automatic compiler screening mode on the basis of ensuring low cost.
Referring to fig. 2, fig. 2 is a flowchart illustrating steps of an intelligent contract compiling and matching method according to a second embodiment of the present invention.
The invention provides an intelligent contract compiling and matching method, which comprises the following steps:
step 201, acquiring intelligent contract data and compiler data from an Ethernet workshop system according to a preset acquisition cycle;
in the embodiment of the present invention, the specific implementation process of step 201 is similar to that of step 101, and is not described herein again.
Step 202, carrying out contract data preprocessing on the intelligent contract data to obtain preprocessed contract data;
optionally, step 202 may include the following sub-steps:
searching intelligent contract data according to a preset contract key value, and determining a corresponding contract address, a contract source code, a contract byte code, a compiling optimization mark and a contract compiler name;
calculating a byte code hash value corresponding to the contract byte code by adopting an SHA256 algorithm;
dividing the name of the compiler according to a preset digit to obtain a hash number of the corresponding contract compiler and a version number of the contract compiler;
and adopting a contract address, a contract source code, a contract byte code, a byte code hash value, a compiling optimization mark, a contract compiler version number and a contract compiler hash number to construct preprocessed contract data.
Contract key values refer to locations corresponding to HTML files within smart Contract data for retrieving portions of data tags within the smart Contract data, such as a Contract Name Contract Name, a Complerversion compiler version, a Contract Source Code Contract Source Code, a Contract Creation Code Contract byte Code, an Optimization Enabled compilation Optimization flag, and so forth.
In the embodiment of the invention, intelligent contract data is retrieved according to the contract key value so as to determine a contract source code, a contract byte code, a compiling optimization identifier and a contract compiler name corresponding to the contract address; after the data is acquired, because the length of the contract bytecode is too long, the time and resources consumed by subsequently and directly comparing the contract bytecode are more, so that a SHA256 algorithm can be further adopted to calculate the bytecode hash value corresponding to the contract bytecode; and dividing the name of the compiler according to preset digits to determine the hash number of the corresponding contract compiler and the version number of the contract compiler.
After the contract address, the contract source code, the contract bytecode, the bytecode hash value, the compilation optimization flag, the contract compiler version number, and the contract compiler hash number are obtained, the data may be used to construct preprocessed contract data, and the data structure is shown in fig. 3.
It should be noted that, the specific calculation process of the SHA-256 algorithm is as follows: the maximum length of the input message is not more than 2^64bit, the input is processed according to 512-bit grouping, and the generated output is a 256-bit message abstract. The algorithm process comprises the following steps:
STEP 1: padding bits are appended. The packet is padded such that the length of the packet is identical to 448 modulo 512 (length 448mod512), the range of the number of bits padded is 1 to 512, the most significant bit of the padding bit string is 1, and the remaining bits are 0. That is, a 1 is added after the message, and then a plurality of 0's are added until the length satisfies mod 512-448, why 448, because 448+ 64-512, the second step is to add a 64-bit length information of the original message.
STEP 2: an additional length value. The bit length of the initial message (before stuffing) represented by 64-bit is appended to the result of step1 (lower byte first).
STEP 3: and (5) initializing the cache. A 256-bit cache is used to store the intermediate and final results of the hash function. The buffer is denoted as a ═ 0x6a09E667, B ═ 0xBB67AE85, C ═ 0x3C6EF372, D ═ 0xA54FF53A, E ═ 0x510E527F, F ═ 0x9B05688C, G ═ 0x1F83D9AB, H ═ 0x5BE0CD 19.
STEP 4: a 512-bit (16 word) sequence of packets is processed. The algorithm uses six basic logic functions and consists of 64 steps of iterative operations. Each step takes 256-bit buffer value ABCDEFGH as input, and then the buffer content is updated. Each step uses a 32-bit constant value Kt and a 32-bit wt.
Step 203, performing compiler data preprocessing on the compiler data to obtain a plurality of preprocessed compiler data;
optionally, step 203 may comprise the sub-steps of:
searching compiler data according to a preset compiler key value, and determining a plurality of corresponding compiler full names;
intercepting the full name of each compiler according to a preset digit to obtain a plurality of corresponding hash numbers of the compiler and a plurality of version numbers of the compiler;
storing the compiler which is fully associated with each compiler, and recording the storage address of the corresponding compiler;
and constructing a plurality of preprocessed compiler data by adopting the full name of a compiler, the version number of the compiler, the Hash number of the compiler and the storage address of the compiler.
Compiler keys refer to information obtained from HTML files that record Compiler data, such as the Compiler Version: compiler versions
In one example of the present invention, compiler data may be retrieved according to a preset compiler key value to determine therefrom a corresponding plurality of compiler full names. And intercepting the full name of the compiler according to preset digits to obtain a compiler hash number and a compiler version number, wherein for example, compiler data is 4.1.1-ac245ac, ac245ac is the compiler hash number, and 4.1.1 is the compiler version number.
And acquiring and storing the corresponding compilers from the Etherhouse system according to the full names of the compilers, and recording the storage addresses of the compilers corresponding to the compilers. And finally, constructing a plurality of preprocessed compiler data by adopting the full name of the compiler, the version number of the compiler, the Hash number of the compiler and the storage address of the compiler, wherein a specific data structure can refer to FIG. 4.
Step 204, matching a plurality of compiler hash numbers according to the contract compiler hash numbers, and judging whether a target compiler hash number identical to the contract compiler hash number exists;
step 205, if yes, obtaining the target compiler from the compiler storage address corresponding to the hash number of the target compiler;
in an example of the present invention, after the contract compiler hash number is obtained, matching may be performed on a matching target and a plurality of compiler hash numbers according to the contract compiler hash number, and determining whether the same target compiler hash number exists therein.
If yes, the target compiler can be obtained from the compiler storage address corresponding to the hash number of the target compiler so as to wait for the follow-up compilation of the intelligent contract.
Step 206, if not, matching a plurality of compiler version numbers according to the contract compiler version number, and judging whether a target compiler version number identical to the contract compiler version number exists;
step 207, if yes, obtaining the target compiler from the compiler storage address corresponding to the target compiler version number;
step 208, if not, generating missing relevant compiler information, and uploading the missing relevant compiler information to a log component in the Etherhouse system;
in another example of the present invention, if there is no target compiler hash number that is the same as the contract compiler hash number, matching is performed again with multiple compiler version numbers according to the contract compiler version number in the preprocessed contract data as a matching target, and it is determined whether there is a target compiler version number that is the same as the contract compiler version number. If yes, acquiring the target compiler from a compiler storage address corresponding to the target compiler version number; if not, the information of the missing relevant compiler can be generated and uploaded to the log component of the Etherhouse so as to generate a corresponding abnormal log.
And step 209, carrying out contract compilation by combining the preprocessed contract data through the target compiler to obtain a compilation result.
Optionally, the compilation result comprises a first compilation result and a second compilation result; step 209 may comprise the following sub-steps:
if the compiling optimization mark is a first preset mark, executing first compiling on the contracted source code through the target compiler to obtain a first compiling result;
and if the compiling optimization mark is a second preset mark, executing second compiling on the contracted source code through the target compiler to obtain a second compiling result.
In the embodiment of the invention, the intelligent contract may or may not need compiling optimization due to user requirements. After the target compiler is selected, the compilation optimization flag can be read by the target compiler to determine the type of compilation optimization required by the intelligent contract data.
If the compiling optimization mark is a first preset mark, executing first compiling on the contracted source code through the target compiler to obtain a first compiling result; and if the compiling optimization mark is a second preset mark, executing second compiling on the contracted source code through the target compiler to obtain a second compiling result.
Further, the method further comprises:
extracting a compiling contract byte code in a compiling result;
calculating a compiled byte code hash value corresponding to the compiled contract byte code by adopting an SHA256 algorithm;
judging whether the compiled byte code hash value is the same as the byte code hash value;
if yes, generating a compiling success prompt;
if not, generating a compiling abnormity prompt and uploading the compiling abnormity prompt to a log component in the Ethernet workshop system.
In another example of the present invention, after the intelligent contract data is compiled, the corresponding compiled contract bytecode may be further extracted from the intelligent contract data, the hash value of the compiled contract bytecode is calculated by using the SHA256 algorithm again, whether the compiling is successful is determined by comparing the compiled contract bytecode with the hash value of the bytecode in the preprocessed contract data, and if the compiled contract bytecode and the preprocessed contract bytecode hash value are the same, the compiling is successful, and a compiling success prompt is generated; if the two are different, the compiling is failed, a compiling abnormity prompt is generated, and the compiling abnormity prompt is uploaded to a log component in the Ethernet workshop system to generate a corresponding compiling abnormity log.
In the embodiment of the invention, intelligent contract data and compiler data are acquired from an Ethernet system according to a preset acquisition cycle; respectively carrying out contract data preprocessing on the intelligent contract data and compiler data preprocessing on the compiler data to obtain preprocessed contract data and a plurality of preprocessed compiler data; matching compiler hash numbers corresponding to the plurality of preprocessed compiler data according to the contract compiler hash numbers in the preprocessed contract data, and acquiring a target compiler from a compiler storage address based on a matching result; and finally, carrying out corresponding contract compilation by combining the compilation optimization marks in the preprocessed contract data through the target compiler to obtain a compilation result corresponding to the intelligent contract data. Therefore, the technical problem that the existing Ether house intelligent contract compiling scheme is difficult to realize low-cost and efficient intelligent contract compiling because the compiler can only be manually screened is solved, and then the intelligent contract compiling is efficiently carried out in an automatic compiler screening mode on the basis of ensuring low cost.
Referring to fig. 5, fig. 5 is a block diagram illustrating an intelligent contract compiling and matching apparatus according to a third embodiment of the present invention.
The embodiment of the invention also provides an intelligent contract compiling and matching device, which comprises:
a data obtaining module 501, configured to obtain intelligent contract data and compiler data from the ethernet system according to a preset obtaining period;
a contract data preprocessing module 502, configured to perform contract data preprocessing on the intelligent contract data to obtain preprocessed contract data;
a compiler data preprocessing module 503, configured to perform compiler data preprocessing on the compiler data to obtain multiple preprocessed compiler data;
a target compiler selection module 504, configured to match multiple pre-processing compiler data according to the pre-processing contract data, and determine a target compiler based on a matching result;
and a compiling module 505, configured to perform contract compiling by using the target compiler in combination with the preprocessed contract data to obtain a compiling result.
Optionally, the contract data preprocessing module 502 is specifically configured to:
searching intelligent contract data according to a preset contract key value, and determining a corresponding contract address, a contract source code, a contract byte code, a compiling optimization mark and a contract compiler name;
calculating a byte code hash value corresponding to the contract byte code by adopting an SHA256 algorithm;
dividing the name of the compiler according to a preset digit to obtain a hash number of the corresponding contract compiler and a version number of the contract compiler;
and adopting a contract address, a contract source code, a contract byte code, a byte code hash value, a compiling optimization mark, a contract compiler version number and a contract compiler hash number to construct preprocessed contract data.
Optionally, the compiler data preprocessing module 503 is specifically configured to:
searching compiler data according to a preset compiler key value, and determining a plurality of corresponding compiler full names;
intercepting the full name of each compiler according to a preset digit to obtain a plurality of corresponding hash numbers of the compiler and a plurality of version numbers of the compiler;
storing the compiler which is fully associated with each compiler, and recording the storage address of the corresponding compiler;
and constructing a plurality of preprocessed compiler data by adopting the full name of a compiler, the version number of the compiler, the Hash number of the compiler and the storage address of the compiler.
Optionally, the target compiler selecting module 504 is specifically configured to:
matching a plurality of compiler hash numbers according to the contract compiler hash number, and judging whether a target compiler hash number identical to the contract compiler hash number exists or not;
if so, acquiring the target compiler from the compiler storage address corresponding to the hash number of the target compiler.
Optionally, the target compiler selection module 504 is further configured to:
if not, matching a plurality of compiler version numbers according to the contract compiler version number, and judging whether a target compiler version number identical to the contract compiler version number exists or not;
if so, acquiring the target compiler from the compiler storage address corresponding to the target compiler version number;
and if not, generating missing relevant compiler information and uploading the missing relevant compiler information to a log component in the Ethernet workshop system.
Optionally, the compilation result comprises a first compilation result and a second compilation result; the compiling module 505 is specifically configured to:
if the compiling optimization mark is a first preset mark, executing first compiling on the contracted source code through the target compiler to obtain a first compiling result;
and if the compiling optimization mark is a second preset mark, executing second compiling on the contracted source code through the target compiler to obtain a second compiling result.
Optionally, the apparatus further comprises:
a compiling contract byte code extracting module for extracting the compiling contract byte code in the compiling result;
the compiling byte code hash value calculating module is used for calculating a compiling byte code hash value corresponding to the compiling contract byte code by adopting an SHA256 algorithm;
the compiled byte code hash judging module is used for judging whether the compiled byte code hash value is the same as the byte code hash value or not;
the compiling success judging module is used for generating a compiling success prompt if the compiling success judging module is used for judging whether the compiling success prompt is successful;
and the compiling abnormity judging module is used for generating a compiling abnormity prompt if the judging result is not positive, and uploading the compiling abnormity prompt to a log component in the Ethernet workshop system.
An embodiment of the present invention further provides an electronic device, which includes a memory and a processor, where the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the intelligent contract compiling and matching method according to any embodiment of the present invention.
Embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed, implements the intelligent contract compiling and matching method according to any embodiment of the present invention.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses and modules may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention 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 solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. An intelligent contract compiling and matching method, comprising:
acquiring intelligent contract data and compiler data from an Ethernet system according to a preset acquisition period;
carrying out contract data preprocessing on the intelligent contract data to obtain preprocessed contract data;
performing compiler data preprocessing on the compiler data to obtain a plurality of preprocessed compiler data;
matching the plurality of preprocessed compiler data according to the preprocessed contract data, and determining a target compiler based on a matching result;
and compiling the contract by combining the target compiler with the preprocessed contract data to obtain a compiling result.
2. The method of claim 1, wherein the step of preprocessing the intelligent contract data to obtain preprocessed contract data comprises:
retrieving the intelligent contract data according to a preset contract key value, and determining a corresponding contract address, a contract source code, a contract byte code, a compiling optimization mark and a contract compiler name;
calculating a byte code hash value corresponding to the contract byte code by adopting an SHA256 algorithm;
dividing the compiler name according to a preset digit to obtain a corresponding contract compiler hash number and a contract compiler version number;
and constructing preprocessed contract data by adopting the contract address, the contract source code, the contract byte code, the byte code hash value, the compiling optimization mark, the contract compiler version number and the contract compiler hash number.
3. The method of claim 2, wherein the step of performing compiler data pre-processing on the compiler data to obtain a plurality of pre-processed compiler data comprises:
retrieving the compiler data according to a preset compiler key value, and determining a plurality of corresponding compiler full names;
intercepting the full name of each compiler according to a preset digit to obtain a plurality of corresponding hash numbers of the compiler and a plurality of version numbers of the compiler;
storing the compiler which is fully associated with each compiler, and recording the storage address of the corresponding compiler;
and constructing a plurality of preprocessed compiler data by adopting the full name of the compiler, the version number of the compiler, the Hash number of the compiler and the storage address of the compiler.
4. A method according to claim 3, wherein said step of matching said plurality of preprocessed compiler data according to said preprocessed contract data, and determining a target compiler based on a result of said matching, comprises:
matching a plurality of compiler hash numbers according to the contract compiler hash number, and judging whether a target compiler hash number identical to the contract compiler hash number exists or not;
and if so, acquiring the target compiler from the compiler storage address corresponding to the hash number of the target compiler.
5. The method of claim 4, further comprising:
if not, matching a plurality of compiler version numbers according to the contract compiler version number, and judging whether a target compiler version number identical to the contract compiler version number exists;
if so, acquiring a target compiler from a compiler storage address corresponding to the target compiler version number;
and if not, generating missing related compiler information and uploading the missing related compiler information to a log component in the Etherhouse system.
6. The method of claim 3, wherein the compilation result comprises a first compilation result and a second compilation result; the step of compiling the contract by combining the target compiler with the preprocessed contract data to obtain a compilation result includes:
if the compiling optimization mark is a first preset mark, executing first compiling on the contract source code through the target compiler to obtain a first compiling result;
and if the compiling optimization mark is a second preset mark, executing second compiling on the contract source code through the target compiler to obtain a second compiling result.
7. The method of claim 3 or 6, further comprising:
extracting a compilation contract bytecode in the compilation result;
calculating a compiled byte code hash value corresponding to the compiled contract byte code by adopting an SHA256 algorithm;
judging whether the compiled byte code hash value is the same as the byte code hash value;
if yes, generating a compiling success prompt;
and if not, generating a compiling abnormity prompt and uploading the compiling abnormity prompt to a log component in the Ethernet workshop system.
8. An intelligent contract compiling matching device, comprising:
the data acquisition module is used for acquiring intelligent contract data and compiler data from the Ethernet workshop system according to a preset acquisition cycle;
the contract data preprocessing module is used for preprocessing the intelligent contract data to obtain preprocessed contract data;
the compiler data preprocessing module is used for performing compiler data preprocessing on the compiler data to obtain a plurality of preprocessed compiler data;
a target compiler selection module, configured to match the plurality of preprocessed compiler data according to the preprocessed contract data, and determine a target compiler based on a matching result;
and the compiling module is used for compiling the contract by combining the target compiler with the preprocessed contract data to obtain a compiling result.
9. An electronic device comprising a memory and a processor, the memory having stored thereon a computer program that, when executed by the processor, causes the processor to perform the steps of the intelligent contract compilation matching method of any of claims 1-7.
10. A computer-readable storage medium having stored thereon a computer program, wherein the computer program, when executed, implements the intelligent contract compilation matching method of any of claims 1-7.
CN202111538095.9A 2021-12-15 2021-12-15 Intelligent contract compiling and matching method, device, equipment and storage medium Pending CN114201176A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111538095.9A CN114201176A (en) 2021-12-15 2021-12-15 Intelligent contract compiling and matching method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111538095.9A CN114201176A (en) 2021-12-15 2021-12-15 Intelligent contract compiling and matching method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114201176A true CN114201176A (en) 2022-03-18

Family

ID=80654210

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111538095.9A Pending CN114201176A (en) 2021-12-15 2021-12-15 Intelligent contract compiling and matching method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114201176A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114676026A (en) * 2022-03-28 2022-06-28 明阳产业技术研究院(沈阳)有限公司 Processor performance test method, device, equipment and medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114676026A (en) * 2022-03-28 2022-06-28 明阳产业技术研究院(沈阳)有限公司 Processor performance test method, device, equipment and medium

Similar Documents

Publication Publication Date Title
CN111033468B (en) System and method for implementing different types of blockchain contracts
TWI730654B (en) Method and device for deploying and executing smart contract
US20200412526A1 (en) Method and apparatus for verifying smart contracts in blockchain, and storage medium
CN111095198B (en) System and method for data processing
WO2019170175A2 (en) System and method for executing different types of blockchain contracts
KR20200083932A (en) System and method for implementing native contract on blockchain
US8261241B2 (en) Converting format strings to regular expressions
CN104346274B (en) Program debugger and a kind of adjustment method of program
CN110825363A (en) Intelligent contract obtaining method and device, electronic equipment and storage medium
WO2021175053A1 (en) Method and apparatus for executing functional module in virtual machine
CN114201176A (en) Intelligent contract compiling and matching method, device, equipment and storage medium
CN111240772A (en) Data processing method and device based on block chain and storage medium
CN114201756A (en) Vulnerability detection method and related device for intelligent contract code segment
CN111984595B (en) File processing method and device and storage medium
CN110059087B (en) Data attribute identification method, device and equipment in block chain type account book
CN116522368A (en) Firmware decryption analysis method for Internet of things equipment, electronic equipment and medium
CN115599394A (en) Serialization and deserialization method, device, computer equipment and storage medium
CN113703753B (en) Method and device for product development and product development system
CN111460436B (en) Unstructured data operation method and system based on blockchain
WO2021217397A1 (en) Node.js component vulnerability detection method and system
CN110825361A (en) Code modification method, device, equipment and readable storage medium
CN117608590B (en) Data group package unpacking method and device and computer equipment
CN116700628B (en) Block chain data processing method, device, computer equipment and storage medium
CN111339574B (en) Block data processing method and device, computer equipment and storage medium
CN116700840B (en) File execution method, device, electronic equipment and readable storage medium

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