Block chain smart contract deployment method and device, computer equipment and storage medium

By conducting code vulnerability detection on smart contracts to be deployed on the blockchain to ensure their security, the problem of security risks caused by direct deployment is solved and the overall security of the blockchain is improved.

CN118821132APending Publication Date: 2024-10-22TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310438069.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-18
Publication Date
2024-10-22

AI Technical Summary

Technical Problem

Directly deploying smart contracts to the blockchain can easily lead to the installation of vulnerable code files, leading to blockchain security risks.

Method used

When receiving a blockchain transaction request, perform code vulnerability detection on the smart contract to be deployed, obtain the vulnerability detection information by obtaining the code status, and deploy only after passing the detection to ensure that the successful smart contract deployment result is written into the smart contract block and written into the blockchain.

Benefits of technology

It effectively avoids deploying vulnerable smart contract code files into the blockchain and improves the security of the blockchain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118821132A_ABST
    Figure CN118821132A_ABST
Patent Text Reader

Abstract

The invention relates to a block chain smart contract deployment method and device, computer equipment, a storage medium and a computer program product. The method comprises the steps of receiving a block chain transaction request, wherein the block chain transaction request carries a to-be-deployed smart contract; generating a smart contract block based on a to-be-deployed smart contract in response to the block chain transaction request, and obtaining a code state corresponding to the to-be-deployed smart contract; acquiring corresponding vulnerability detection information based on the code state, and performing code vulnerability detection on the to-be-deployed smart contract by using the vulnerability detection information; when the code vulnerability detection on the to-be-deployed smart contract is passed, deploying the to-be-deployed smart contract to obtain a smart contract deployment success result; and writing a smart contract deployment success result into the smart contract block to obtain a target smart contract block, and writing the target smart contract block into the block chain. By adopting the method, the security of the block chain can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a blockchain smart contract deployment method, apparatus, computer equipment, storage medium and computer program product. Background Art

[0002] With the development of blockchain technology, smart contract technology has emerged. Smart contracts are programs that run on blockchains. Smart contracts must ensure that the results of running in every node of the blockchain network are exactly the same, so that any node can verify whether the results of the smart contract execution in the block are correct. At present, when smart contracts are deployed to blockchains, they are usually deployed directly to the blockchain for use. However, directly deploying smart contracts to blockchains can easily install smart contract code files with vulnerabilities into the blockchain, resulting in security risks to the blockchain. Summary of the invention

[0003] Based on this, it is necessary to provide a blockchain smart contract deployment method, device, computer equipment, computer-readable storage medium and computer program product that can improve security in response to the above-mentioned technical problems.

[0004] In a first aspect, the present application provides a blockchain smart contract deployment method. The method comprises:

[0005] Receive blockchain transaction requests, which carry the smart contract to be deployed;

[0006] Respond to blockchain transaction requests to generate smart contract blocks based on the smart contract to be deployed, and obtain the code status corresponding to the smart contract to be deployed;

[0007] Obtain corresponding vulnerability detection information based on the code status, and use the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed;

[0008] When the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is deployed and a successful smart contract deployment result is obtained;

[0009] Write the successful result of smart contract deployment into the smart contract block, obtain the target smart contract block, and write the target smart contract block into the blockchain.

[0010] In a second aspect, the present application also provides a blockchain smart contract deployment device. The device includes:

[0011] A request receiving module is used to receive a blockchain transaction request, which carries a smart contract to be deployed;

[0012] The status acquisition module is used to respond to the blockchain transaction request, generate a smart contract block based on the smart contract to be deployed, and obtain the code status corresponding to the smart contract to be deployed;

[0013] The code detection module is used to obtain the corresponding vulnerability detection information based on the code status, and use the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed;

[0014] The deployment module is used to deploy the smart contract to be deployed when the code vulnerability detection of the smart contract to be deployed passes, and obtain the result of successful deployment of the smart contract;

[0015] The block writing module is used to write the successful result of smart contract deployment into the smart contract block, obtain the target smart contract block, and write the target smart contract block into the blockchain.

[0016] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0017] Receive blockchain transaction requests, which carry the smart contract to be deployed;

[0018] Respond to blockchain transaction requests to generate smart contract blocks based on the smart contract to be deployed, and obtain the code status corresponding to the smart contract to be deployed;

[0019] Obtain corresponding vulnerability detection information based on the code status, and use the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed;

[0020] When the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is deployed and a successful smart contract deployment result is obtained;

[0021] Write the successful result of smart contract deployment into the smart contract block, obtain the target smart contract block, and write the target smart contract block into the blockchain.

[0022] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0023] Receive blockchain transaction requests, which carry the smart contract to be deployed;

[0024] Respond to blockchain transaction requests to generate smart contract blocks based on the smart contract to be deployed, and obtain the code status corresponding to the smart contract to be deployed;

[0025] Obtain corresponding vulnerability detection information based on the code status, and use the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed;

[0026] When the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is deployed and a successful smart contract deployment result is obtained;

[0027] Write the successful result of smart contract deployment into the smart contract block, obtain the target smart contract block, and write the target smart contract block into the blockchain.

[0028] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0029] Receive blockchain transaction requests, which carry the smart contract to be deployed;

[0030] Respond to blockchain transaction requests to generate smart contract blocks based on the smart contract to be deployed, and obtain the code status corresponding to the smart contract to be deployed;

[0031] Obtain corresponding vulnerability detection information based on the code status, and use the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed;

[0032] When the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is deployed and a successful smart contract deployment result is obtained;

[0033] Write the successful result of smart contract deployment into the smart contract block, obtain the target smart contract block, and write the target smart contract block into the blockchain.

[0034] The above-mentioned blockchain smart contract deployment method, device, computer equipment, storage medium and computer program product receive a blockchain transaction request, the blockchain transaction request carries the smart contract to be deployed, generates a smart contract block based on the smart contract to be deployed in response to the blockchain transaction request, and obtains the code status corresponding to the smart contract to be deployed. Based on the code status, the corresponding vulnerability detection information is obtained, and the code vulnerability detection is performed on the smart contract to be deployed using the vulnerability detection information; when the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is deployed to obtain a successful result of smart contract deployment; the successful result of smart contract deployment is written into the smart contract block to obtain the target smart contract block, and the target smart contract block is written into the blockchain, that is, when a transaction request for blockchain smart contract deployment is received, the code vulnerability detection of the deployed smart contract is performed during the execution of the transaction request, and then when the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is deployed to the blockchain, thereby avoiding the deployment of smart contract code files with vulnerabilities into the blockchain, thereby avoiding the security risks of the blockchain and improving the security of the blockchain. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 An application environment diagram of a blockchain smart contract deployment method in one embodiment;

[0036] Figure 2 A flowchart of a blockchain smart contract deployment method in one embodiment;

[0037] Figure 3 A schematic diagram of a process of detecting a code vulnerability in an embodiment;

[0038] Figure 4 A schematic diagram of a flow chart of code vulnerability detection in another embodiment;

[0039] Figure 5 It is a schematic diagram of the process of deploying a smart contract in a specific embodiment;

[0040] Figure 6 A schematic diagram of a process of remotely deploying a smart contract in one embodiment;

[0041] Figure 7 A schematic diagram of a process for remotely executing a smart contract in one embodiment;

[0042] Figure 8 A schematic diagram of the process of blockchain smart contract deployment in a specific embodiment;

[0043] Fig. 9 A schematic diagram of a process of updating a blockchain smart contract in one embodiment;

[0044] Fig.10A flowchart of a blockchain smart contract update in a specific embodiment;

[0045] Fig.11 A flowchart of a blockchain smart contract deployment method in a specific embodiment;

[0046] Fig.12 A schematic diagram of the architecture of blockchain smart contract deployment in a specific embodiment;

[0047] Fig.13 It is a structural block diagram of a blockchain smart contract deployment device in one embodiment;

[0048] Fig.14 is an internal structure diagram of a computer device in one embodiment;

[0049] Fig.15 FIG. 4 is a diagram showing the internal structure of a computer device in another embodiment. DETAILED DESCRIPTION

[0050] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0051] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.

[0052] The underlying blockchain platform can include processing modules such as user management, basic services, smart contracts, and operations. Among them, the user management module is responsible for the identity information management of all blockchain participants, including maintaining the generation of public and private keys (account management), key management, and the maintenance of the correspondence between the user's real identity and the blockchain address (authority management), etc., and, under authorization, supervises and audits the transactions of certain real identities and provides risk control rule configuration (risk control audit); the basic service module is deployed on all blockchain node devices to verify the validity of business requests, and records valid requests to storage after consensus is reached. For a new business request, the basic service first performs interface adaptation analysis and authentication processing (interface adaptation), and then encrypts the business information through the consensus algorithm (consensus Management), and after encryption, it is transmitted completely and consistently to the shared ledger (network communication), and recorded and stored; the smart contract module is responsible for the registration and issuance of contracts, as well as contract triggering and contract execution. Developers can define the contract logic in a programming language and publish it to the blockchain (contract registration). According to the logic of the contract terms, the key or other events are called to trigger the execution to complete the contract logic. At the same time, it also provides the function of contract upgrade and cancellation; the operation module is mainly responsible for the deployment, configuration modification, contract setting, cloud adaptation and real-time status visualization output of the product during the product release process, such as alarm, network status detection, node equipment health status detection, etc.

[0053] The platform product service layer provides the basic capabilities and implementation framework of typical applications. Developers can superimpose business features based on these basic capabilities to complete the blockchain implementation of business logic. The application service layer provides application services based on blockchain solutions for business participants to use.

[0054] The blockchain smart contract deployment method provided in the embodiment of the present application can be applied to Figure 1In the application environment shown. Among them, the terminal 102 communicates with the blockchain node 104 through the network. The data storage system can store the data that the blockchain node 104 needs to process. The data storage system can be integrated on the blockchain node 104, or it can be placed on the cloud or other servers. The blockchain node 104 receives a blockchain transaction request, and the blockchain transaction request carries the smart contract to be deployed; the blockchain node 104 responds to the blockchain transaction request to generate a smart contract block based on the smart contract to be deployed, and obtains the code status corresponding to the smart contract to be deployed. The blockchain node 104 obtains the corresponding vulnerability detection information based on the code status, and uses the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed; when the blockchain node 104 passes the code vulnerability detection of the smart contract to be deployed, the smart contract to be deployed is deployed, and the smart contract deployment success result is obtained; the blockchain node 104 writes the smart contract deployment success result into the smart contract block, obtains the target smart contract block, and writes the target smart contract block into the blockchain. The blockchain node 104 returns a prompt message that the smart contract deployment is completed to the terminal 102. Among them, the blockchain node can be implemented by an independent server or a server cluster composed of multiple servers, and the blockchain node can also be implemented by a terminal. The terminal may be, but is not limited to, various desktop computers, laptops, smart phones, tablet computers, IoT devices and portable wearable devices. IoT devices may be smart speakers, smart TVs, smart air conditioners, smart car devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc.

[0055] In one embodiment, Figure 2 As shown, a blockchain smart contract deployment method is provided, which is applied to Figure 1 The blockchain node in is used as an example to illustrate, including the following steps:

[0056] S202, receiving a blockchain transaction request, where the blockchain transaction request carries a smart contract to be deployed.

[0057] Among them, the blockchain transaction request refers to the transaction request used to deploy the smart contract in the blockchain. The smart contract to be deployed refers to the smart contract that needs to be deployed in the blockchain. After the deployment is completed, the nodes in the blockchain can use the smart contract.

[0058] Specifically, the blockchain node can receive a blockchain transaction request sent by a terminal, and then parse the blockchain transaction request to obtain the smart contract to be deployed carried by the blockchain transaction request. The blockchain node can also receive a blockchain transaction request sent by a business server, which can be a server that provides business services related to blockchain.

[0059] S204, responding to the blockchain transaction request, generating a smart contract block based on the smart contract to be deployed, and obtaining the code status corresponding to the smart contract to be deployed.

[0060] Among them, the smart contract block refers to the block where the specific content of the smart contract is written. The smart contract block is a block without consensus and is a block that has not been written into the blockchain. The code state is used to characterize the state of the implementation code corresponding to the smart contract, including binary code state and non-binary code state. The binary code state is used to characterize that the implementation code of the smart contract to be deployed is binary code, and the binary code is compiled code. The non-binary code state is used to characterize that the implementation code of the smart contract to be deployed is non-binary code. The non-binary code can be source code, even code before compilation.

[0061] Specifically, the blockchain node responds to the blockchain transaction request and uses the smart contract to be deployed to generate the corresponding smart contract block, wherein the blockchain node generates a timestamp, a hash of the current block, and then obtains the hash of the previous block and the height of the current block, and then uses the timestamp, the hash of the current block, the hash of the previous block, the height of the current block and the smart contract to be deployed to generate the corresponding smart contract block, that is, the smart contract to be deployed is used as transaction data to generate the corresponding smart contract block. Then the blockchain node executes the blockchain transaction request, that is, the deployment of the smart contract to be deployed is performed. At this time, the blockchain node first needs to perform code vulnerability detection on the smart contract to be deployed, that is, the blockchain node first obtains the code status corresponding to the smart contract to be deployed, wherein the corresponding code status can be determined according to whether the code in the smart contract file to be deployed is binary, for example, when the smart contract file to be deployed is detected as a binary file, the code status of the smart contract to be deployed is determined to be a binary code status, and when the smart contract file to be deployed is detected to be not a binary file, for example, when it is a source code file, the code status of the smart contract to be deployed is determined to be a non-binary code status.

[0062] In one embodiment, the blockchain node may first write the transaction of the smart contract deployment corresponding to the blockchain transaction request into the transaction pool of the blockchain, and then the blockchain selects the transaction request from the transaction pool to package the block, and the selected transaction request may include the transaction request for deploying the smart contract.

[0063] In one embodiment, when a blockchain node receives a blockchain transaction request, it first verifies the authority and legitimacy of the blockchain transaction request. Among them, the blockchain transaction request can carry a digital certificate representing the identity of the user, and the digital certificate is used to verify whether the user is a legitimate blockchain user. When the digital certificate is verified, it means that the user has the authority to conduct blockchain transactions. At this time, the blockchain node responds to the blockchain transaction request to generate a smart contract block based on the smart contract to be deployed, and performs code vulnerability detection on the smart contract to be deployed. A digital certificate (or simply a certificate) is an electronic file that uniquely identifies a person or resource on the Internet. A certificate enables secure and confidential communication between two entities. There are many types of certificates, such as personal certificates (used by individuals) and server certificates (used to establish a secure session between a server and a client through Secure Sockets Layer [SSL] technology).

[0064] S206, obtaining corresponding vulnerability detection information based on the code status, and using the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed.

[0065] Among them, vulnerability detection information refers to the information for calling vulnerability detection tools, for example, it can be the calling information of the detection interface or the identification of the detection tool, etc. Different code states correspond to different vulnerability detection information, and the corresponding relationship between code states and vulnerability detection information is pre-set. Code vulnerability detection refers to the detection of vulnerabilities in the code of smart contracts.

[0066] Specifically, the blockchain node obtains the vulnerability detection information corresponding to the code state of the smart contract to be deployed according to the correspondence between the code state and the vulnerability detection information, and then uses the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed. Code vulnerability detection can be performed from different dimensions, and the blockchain node can perform code vulnerability detection from the static code dimension, dynamic code dimension, runtime dimension, and code composition dimension.

[0067] S208: When the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is deployed.

[0068] Get the successful result of smart contract deployment.

[0069] Among them, code vulnerability detection passing means that the code vulnerability detection passes when no vulnerability is detected in the code of the smart contract to be deployed. Specifically, the blockchain node uses the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed. Code vulnerability detection can be performed by calling an interface, or by using vulnerability detection tools corresponding to each dimension. Then, when the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is stored in the deployment address corresponding to the deployment address information, that is, the blockchain node stores the code file corresponding to the smart contract to be deployed to the deployment address. Then the blockchain node initializes the smart contract to be deployed, that is, instantiates the instance object in the smart contract to be deployed. At this time, the smart contract deployment is completed. The blockchain node obtains the result of successful deployment of the smart contract.

[0070] In one embodiment, the smart contract to be deployed can be first stored in the cache pool, and then stored in the deployment address corresponding to the deployment address information. When the smart contract to be deployed needs to be used, the smart contract to be deployed can be directly called from the cache pool for use, avoiding repeated acquisition of smart contract files from storage, improving efficiency, and ensuring the security of the smart contract.

[0071] S210, write the successful result of smart contract deployment into the smart contract block, obtain the target smart contract block, and write the target smart contract block into the blockchain.

[0072] The target smart contract block refers to the block in which the smart contract to be deployed and the result of successful smart contract deployment are written. That is, it refers to the block generated after the transaction request is executed and includes all transaction data after the transaction is executed.

[0073] Specifically, when the blockchain node completes the smart contract deployment, it writes the successful result of the smart contract deployment into the smart contract block, obtains the target smart contract block, and finally writes the target smart contract block into the blockchain, that is, the target smart contract block is consensus-based in the blockchain through the consensus mechanism, and when the consensus is passed, it is written into the blockchain, that is, the target smart contract block is stored in the blockchain ledger in an appended manner, and the status data of the blockchain is updated.

[0074] The above-mentioned blockchain smart contract deployment method, device, computer equipment, storage medium and computer program product receive a blockchain transaction request, the blockchain transaction request carries the smart contract to be deployed, responds to the blockchain transaction request, generates a smart contract block based on the smart contract to be deployed, and obtains the code status corresponding to the smart contract to be deployed; obtains the corresponding vulnerability detection information based on the code status, and uses the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed; when the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is deployed to obtain a successful smart contract deployment result; the successful smart contract deployment result is written into the smart contract block to obtain a target smart contract block, and the target smart contract block is written into the blockchain, that is, when a transaction request for blockchain smart contract deployment is received, a code vulnerability detection is performed on the deployed smart contract during the execution of the transaction request, and then when the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is deployed to the blockchain, thereby avoiding the deployment of smart contract code files with vulnerabilities into the blockchain, thereby avoiding the security risks of the blockchain and improving the security of the blockchain.

[0075] In one embodiment, S204, obtaining corresponding vulnerability detection information based on the code status, and using the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed, includes the following steps:

[0076] When the code state is a binary code state, vulnerability detection is performed on the smart contract to be deployed based on the software component vulnerability detection information corresponding to the binary code state; when the code state is a non-binary code state, vulnerability detection is performed on the smart contract to be deployed based on each preset vulnerability detection information corresponding to the non-binary code state.

[0077] Among them, the code state is used to characterize the state of the implementation code corresponding to the smart contract. The code type may include binary code state and non-binary code state. The binary code state refers to the state in which the implementation code in the smart contract file is binary code. The non-binary code state refers to the state in which the implementation code in the smart contract file is non-binary, which may be the state of the source code. The software component vulnerability detection information refers to the information used for software component vulnerability detection. The software component vulnerability detection information may be the call information of the software component vulnerability detection tool, or the call information of the software component vulnerability detection interface, etc. The preset vulnerability detection information refers to the information for vulnerability detection in different dimensions that is pre-set. Each preset vulnerability detection information can perform vulnerability detection on the code of the smart contract in different dimensions. Specifically, the blockchain node determines the code state corresponding to the smart contract to be deployed, that is, determines whether the code in the smart contract file to be deployed is binary code. Among them, it may be to read the code in the smart contract file to be deployed. When the code is compiled code, the code state corresponding to the smart contract to be deployed is binary code state. When the code in the smart contract file to be deployed is source code, the code state corresponding to the smart contract to be deployed is non-binary code state. Then the blockchain node determines that when the code type is in a binary code state, vulnerability detection is performed on the smart contract to be deployed based on the software component vulnerability detection information corresponding to the binary code state. For example, when the code in the smart contract file to be deployed is binary code, the SCA (Software Composition Analysis) tool can be used to perform software component vulnerability detection on the smart contract file of the binary code. The SCA tool performs vulnerability detection by comparing the components in the smart contract file of the binary code with the known open source vulnerability database. Then the blockchain node determines that when the code type is in a non-binary code state, vulnerability detection is performed on the smart contract to be deployed based on the various preset vulnerability detection information corresponding to the non-binary code state.

[0078] In one embodiment, when the code state is a binary code state, vulnerability detection is performed on the smart contract to be deployed based on the software component vulnerability detection information corresponding to the binary code state. When the vulnerability detection of the smart contract to be deployed using the software component vulnerability detection information passes, it is determined that the code vulnerability detection of the smart contract to be deployed passes. When the vulnerability detection of the smart contract to be deployed using the software component vulnerability detection information fails, it is determined that the code vulnerability detection of the smart contract to be deployed fails.

[0079] In the above embodiment, by obtaining the code state corresponding to the smart contract to be deployed, when the code state is a binary code state, vulnerability detection is performed on the smart contract to be deployed based on the software component vulnerability detection information corresponding to the binary code state. When the code state is a non-binary code state, vulnerability detection is performed on the smart contract to be deployed based on each preset vulnerability detection information corresponding to the non-binary code state, so that vulnerability detection can be performed on the smart contract of the binary code and the smart contract of the non-binary code respectively, thereby improving the accuracy of vulnerability detection.

[0080] In one embodiment, Figure 3 As shown, vulnerability detection is performed on the deployed smart contract based on various preset vulnerability detection information corresponding to the non-binary code state, including:

[0081] S302, performing static code vulnerability detection on the smart contract to be deployed based on the static code vulnerability detection information corresponding to the non-binary code state.

[0082] Among them, static code vulnerability detection information refers to the information of the implementation code corresponding to the smart contract under static detection. Static detection refers to the detection of the semantics and behavior of the implementation code corresponding to the smart contract without execution, so as to detect whether there is a code vulnerability. The static code vulnerability detection information can be the call information of the static code vulnerability detection tool, the call information of the static code vulnerability detection interface, etc.

[0083] Specifically, the blockchain node uses the static code vulnerability detection information corresponding to the non-binary code state to perform static code vulnerability detection on the smart contract to be deployed. For example, SAST (Static Application Security Testing) can be used to perform static code detection on the smart contract to detect whether there are vulnerabilities in the implementation code of the smart contract. SAST can detect the syntax, structure, process, interface, etc. of the source code of the smart contract to discover vulnerabilities in the program code. SAST is a white box testing technology. When no vulnerabilities are found through SAST detection, it is determined that the static code vulnerability detection has passed. When vulnerabilities are found through SAST detection, it is determined that the static code vulnerability detection has failed.

[0084] S304: When the static code vulnerability detection passes, dynamic code vulnerability detection is performed on the smart contract to be deployed based on the dynamic code vulnerability detection information corresponding to the non-binary code state.

[0085] Among them, dynamic code vulnerability detection information refers to the information of the implementation code corresponding to the smart contract under dynamic detection. Dynamic detection refers to the code vulnerability detection performed when the implementation code corresponding to the smart contract is executed. The dynamic code vulnerability detection information can be the call information of the dynamic code vulnerability detection tool, the call information of the dynamic code vulnerability detection interface, etc.

[0086] Specifically, when the blockchain node determines that the static code vulnerability detection has passed, the dynamic code vulnerability detection information corresponding to the non-binary code state is used to perform dynamic code vulnerability detection on the smart contract to be deployed. For example, DAST (Dynamic Application Security Testing) can be used to perform dynamic code detection on the smart contract to detect whether there are vulnerabilities in the implementation code of the smart contract. DAST can be used to test the running smart contract from the outside, simulating hacker attacks to detect vulnerabilities in the runtime. DAST is a black box testing technology. When no vulnerabilities are found through DAST detection, it is determined that the dynamic code vulnerability detection has passed. When vulnerabilities are found through DAST detection, it is determined that the dynamic code vulnerability detection has not passed.

[0087] S306, when the dynamic code vulnerability detection passes, an interactive application security detection is performed on the smart contract to be deployed based on the interactive application security detection information corresponding to the non-binary code state. When the interactive application security detection passes, it is determined that the code vulnerability detection of the smart contract to be deployed has passed.

[0088] The interactive application security detection information refers to information for performing interactive application security detection, and can be calling information of an interactive application security detection tool, calling information of an interactive application security detection interface, and the like.

[0089] Specifically, the blockchain node determines that when the dynamic code vulnerability detection passes, the interactive application security detection is performed on the smart contract to be deployed based on the interactive application security detection information corresponding to the non-binary code state. For example, IAST (Interactive application security testing) can be used to perform dynamic code detection on the smart contract to detect whether there are vulnerabilities in the implementation code of the smart contract. IAST collects and monitors the execution of application runtime functions and data transmission through agents, virtual private networks, or deploys agents on the server side, and interacts with the scanner side in real time, efficiently and accurately identifies security defects and vulnerabilities, and can accurately determine the code files, lines, functions and parameters where the vulnerabilities are located. IAST is a gray box testing technology. When no vulnerabilities are detected by IAST, it is determined that the interactive application security detection has passed. When there are vulnerabilities detected by IAST, it is determined that the interactive application security detection has not passed. When the interactive application security detection passes, it is determined that the code vulnerability detection of the smart contract to be deployed has passed. That is, when the static code vulnerability detection, dynamic code vulnerability detection and interactive application security detection are all passed, it is determined that the code vulnerability detection of the smart contract to be deployed has passed. When one of the static code vulnerability detection, dynamic code vulnerability detection, and interactive application security detection fails, it is determined that the code vulnerability detection of the smart contract to be deployed has failed.

[0090] In the above embodiment, static code vulnerability detection is performed on the smart contract to be deployed based on the static code vulnerability detection information corresponding to the non-binary code state, dynamic code vulnerability detection is performed on the smart contract to be deployed based on the dynamic code vulnerability detection information corresponding to the non-binary code state, and interactive application security detection is performed on the smart contract to be deployed based on the interactive application security detection information corresponding to the non-binary code state. Only when the static code vulnerability detection, the dynamic code vulnerability detection and the interactive application security detection are all passed, it can be determined that the code vulnerability detection of the smart contract to be deployed has passed, thereby improving the accuracy of code vulnerability detection.

[0091] In one embodiment, Figure 4 As shown, the blockchain smart contract deployment method also includes:

[0092] S402, obtaining a target signature corresponding to the smart contract to be deployed, where the target signature is obtained by digitally signing the smart contract to be deployed after passing the code vulnerability detection.

[0093] Among them, the target signature is obtained by digitally signing the smart contract to be deployed after passing the code vulnerability detection. The target signature can be obtained by the blockchain node digitally signing the smart contract to be deployed after passing the code vulnerability detection. The target signature can also be obtained by the service device that performs digital signature on the smart contract to be deployed after passing the code vulnerability detection, and then the blockchain node obtains it from the service device.

[0094] Specifically, the blockchain node can obtain the target signature corresponding to the smart contract to be deployed from the blockchain transaction request. The target signature is a digital signature that needs to be verified. The target signature can be obtained by performing code vulnerability detection on the smart contract to be deployed, and after the code vulnerability detection passes, the smart contract to be deployed is digitally signed.

[0095] Among them, the code vulnerability detection for the smart contract to be deployed can be that when the code in the code file of the smart contract to be deployed is binary code, the vulnerability detection of the smart contract to be deployed is performed through the software component vulnerability detection information. When the code in the code file of the smart contract to be deployed is non-binary code, static code vulnerability detection is performed on the smart contract to be deployed, dynamic code vulnerability detection is performed on the smart contract to be deployed, and interactive application security detection is performed on the smart contract to be deployed. When the software component vulnerability detection passes or when the static code vulnerability detection, dynamic code vulnerability detection, and interactive application security detection are all passed, it means that the code vulnerability detection of the smart contract to be deployed has passed.

[0096] Among them, digitally signing the smart contract to be deployed can be to calculate the hash value of the smart contract to be deployed, digitally sign the hash value, and obtain the target signature. In one embodiment, it can be that other devices perform code vulnerability detection on the smart contract to be deployed and pass it, and then digitally sign the smart contract to be deployed to obtain the target signature. The other device can be a device that does not deploy blockchain, for example, it can be a server used only for code vulnerability detection. In one embodiment, it can also be that the blockchain node performs code vulnerability detection on the smart contract to be deployed and pass it, and then digitally sign the smart contract to be deployed to obtain the target signature.

[0097] In one embodiment, the blockchain node obtains a transaction request, which carries the identity digital signature, the target signature, and the smart contract to be deployed. The blockchain node first verifies the identity digital signature, and when it verifies that it has the authority to conduct blockchain transactions, it verifies the target signature. When the target signature is verified, the blockchain node executes the transaction request to deploy the smart contract to be deployed.

[0098] S404, calculate the contract hash corresponding to the smart contract to be deployed, and digitally sign the contract hash to obtain a contract signature.

[0099] The contract hash refers to the hash value of the smart contract to be deployed calculated using the hash algorithm. The contract signature is the digital signature of the smart contract to be deployed calculated by the blockchain node.

[0100] Specifically, the blockchain node uses a hash algorithm to calculate the contract hash corresponding to the smart contract to be deployed. The hash algorithm can be to transform the smart contract to be deployed into an output of fixed length through a hash algorithm to obtain a hash value, or to extract the key part of the smart contract to be deployed, and transform the key part into an output of fixed length through a hash algorithm to obtain a hash value. Then, a digital signature algorithm is used to digitally sign the contract hash to obtain a contract signature. The digital signature algorithm can be an RSA algorithm, a DSA algorithm, an elliptic curve digital signature algorithm, and the like.

[0101] S406, determining the vulnerability detection result of the smart contract code to be deployed based on the consistency of the contract signature and the target signature.

[0102] Specifically, the blockchain node determines the consistency of the contract signature and the target signature. When the contract signature and the target signature are consistent, it means that the smart contract to be deployed obtained by the blockchain node is a smart contract that has passed the code vulnerability detection. At this time, the blockchain node can directly deploy the smart contract to be deployed. When the contract signature and the target signature are not consistent, it means that the smart contract to be deployed obtained by the blockchain node is not a smart contract that has passed the code vulnerability detection. At this time, the blockchain node can perform code vulnerability detection on the smart contract to be deployed, that is, obtain the code status corresponding to the smart contract to be deployed. Based on the code status, the corresponding vulnerability detection information is obtained, and the vulnerability detection information is used to perform code vulnerability detection on the smart contract to be deployed. Finally, when the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is deployed to obtain the successful result of smart contract deployment, and the successful result of smart contract deployment is written into the smart contract block to obtain the target smart contract block, and the target smart contract block is written into the blockchain.

[0103] In a specific embodiment, Figure 5As shown in the figure, it is a flow chart of deploying smart contracts in blockchain nodes. Specifically, the user writes the smart contract to be deployed in a programming language. Then the smart contract is sent to the contract audit center server for code vulnerability detection. The contract audit center server receives the smart contract uploaded by the user through the terminal, and performs a security audit check on the smart contract, that is, code vulnerability detection. That is, the contract audit center server determines whether the smart contract code file is a binary code file. When the smart contract code file is a binary code file, the contract audit center server performs code vulnerability detection through the SCA tool. At this time, when the code vulnerability detection fails, the error result of code vulnerability detection failure is returned to the user's terminal. When the code vulnerability detection passes, the target signature corresponding to the smart contract is calculated, and the target signature is returned to the user's terminal. When the smart contract code file is not a binary code file, the contract audit center server performs code vulnerability detection through the SAST tool. At this time, when the code vulnerability detection passes, the code vulnerability detection is performed through the DAST tool. At this time, when the code vulnerability detection passes, the code vulnerability detection is performed through the IAST tool. At this time, it means that the vulnerability detection of the smart contract code has passed. The contract audit center server then calculates the contract hash corresponding to the smart contract, then digitally signs the contract hash to obtain the target signature, and returns the target signature to the user's terminal. The user then encapsulates the target signature and smart contract file through the terminal, and sends the encapsulated target signature and smart contract file to the blockchain node in the form of a transaction request. The blockchain node receives the transaction request, performs hash calculation on the smart contract file to obtain the contract hash, then digitally signs the contract hash to obtain the contract signature, and then verifies whether the contract signature is correct, that is, whether the contract signature is consistent with the target signature. When the contract signature is inconsistent with the target signature, the error result that the smart contract has not passed the code vulnerability detection is returned to the user's terminal. When the contract signature is consistent with the target signature, the blockchain node responds to the transaction request to execute the subsequent deployment tasks of the blockchain. When the deployment is completed, the correct result of the completion of the smart contract deployment is returned to the user's terminal.

[0104] In the above embodiment, by obtaining the target signature corresponding to the smart contract to be deployed, the target signature is obtained by digitally signing the smart contract to be deployed after passing the code vulnerability detection. The contract hash corresponding to the smart contract to be deployed is calculated, and the contract hash is digitally signed to obtain the contract signature. Based on the consistency of the contract signature and the target signature, the code vulnerability detection result of the smart contract to be deployed is determined, so that the blockchain node can avoid code vulnerability detection on the basis of ensuring that the smart contract code vulnerability detection passes, thereby saving the computing resources of the blockchain node, that is, separating the code vulnerability detection from the blockchain node, thereby avoiding the blockchain from consuming more computing resources for contract auditing, thereby ensuring that the blockchain can efficiently execute and package transactions.

[0105] In one embodiment, after S204, after generating a smart contract block based on the smart contract to be deployed in response to the blockchain transaction request and performing code vulnerability detection on the smart contract to be deployed, the following steps are also included:

[0106] When the code vulnerability detection of the smart contract to be deployed fails, a smart contract deployment failure result is obtained; the smart contract deployment failure result is written into the smart contract block, the current smart contract block is obtained, and the current smart contract block is written into the blockchain.

[0107] Among them, the smart contract deployment failure result is used to characterize the result of the smart contract deployment failure. The current smart contract block refers to the block in which the smart contract deployment failure result and the smart contract to be deployed are written.

[0108] Specifically, when the blockchain node detects that the code vulnerability detection of the smart contract to be deployed fails, the smart contract deployment failure result is obtained. At this time, in order to ensure the normal progress of the blockchain transaction, the blockchain node writes the smart contract deployment failure result into the smart contract block, obtains the current smart contract block, and then writes the current smart contract block into the blockchain.

[0109] In the above embodiment, when the code vulnerability detection of the smart contract to be deployed fails, the smart contract deployment failure result is obtained. Then the smart contract deployment failure result is written into the smart contract block to obtain the current smart contract block, and then the current smart contract block is written into the blockchain, so that the blockchain can be executed and packaged normally, and the current smart contract block is written into the blockchain to ensure the security of information.

[0110] In one embodiment, S206, deploying the smart contract to be deployed to obtain a smart contract deployment result includes the following steps:

[0111] Determine the deployment type of the smart contract to be deployed based on the code language type of the smart contract to be deployed, and obtain the deployment address information of the smart contract to be deployed based on the deployment type. Store the smart contract to be deployed at the deployment address corresponding to the deployment address information, initialize the smart contract to be deployed, and obtain the result of successful deployment of the smart contract.

[0112] Among them, the code language type is used to characterize the type of programming language used when the smart contract to be deployed is written. Smart contracts written in different programming languages ​​correspond to different code language types. Each smart contract programming language corresponds to a code language type. Deployment address information refers to the specific address information when the smart contract is deployed, and the address information can be pre-set. Different code language types correspond to different deployment address information, and the deployment address information can be the information of the specific address in the blockchain node, or the specific address information during independent deployment. Independent deployment refers to deployment in devices other than nodes in the blockchain. Deployment type is used to characterize the type of deployment method when the smart contract to be deployed is deployed. The deployment type includes the same-process deployment type, containerized deployment type, and remote deployment type. The deployment method includes same-process deployment, containerized deployment, and remote deployment. Smart contracts in different languages ​​correspond to different deployment methods. Deployment address refers to the specific path address used during deployment. Initializing the smart contract to be deployed refers to initializing the state of the smart contract so that the smart contract can be used directly.

[0113] Specifically, the blockchain node determines the deployment type corresponding to the smart contract to be deployed based on the code language type corresponding to the smart contract to be deployed, that is, different smart contract languages ​​correspond to different code language types, and the addresses for deployment and execution of smart contracts of different code language types. The blockchain can support smart contracts in different programming languages. The smart contracts in different programming languages ​​can be deployed and executed in independent devices or directly deployed and executed in the current process of the blockchain. Then the blockchain node obtains the deployment address information corresponding to the smart contract to be deployed from the database according to the deployment type. The database can pre-set the corresponding relationship table between the deployment type and the deployment address information. Then, the deployment address information corresponding to the deployment type can be searched in the corresponding relationship table in the database, so as to obtain the deployment address information corresponding to the smart contract to be deployed. Finally, the blockchain node stores the code file corresponding to the smart contract to be deployed to the deployment address. Then, the instance object in the smart contract to be deployed is instantiated. At this time, the smart contract deployment is completed. The blockchain node obtains the result of successful deployment of the smart contract.

[0114] In the above embodiment, the deployment type corresponding to the smart contract to be deployed is determined based on the code language type corresponding to the smart contract to be deployed, and then the deployment type is used to obtain the deployment address information corresponding to the smart contract to be deployed, the smart contract to be deployed is stored in the deployment address corresponding to the deployment address information, and the smart contract to be deployed is initialized to obtain a successful deployment result of the smart contract. By obtaining the corresponding deployment address information through the deployment type and then deploying, the accuracy of smart contract deployment can be improved.

[0115] In one embodiment, S208, storing the smart contract to be deployed to the deployment address corresponding to the deployment address information, and initializing the smart contract to be deployed, and obtaining a successful result of the smart contract deployment, includes the steps of:

[0116] When the deployment type is the same-process deployment type, the smart contract to be deployed is stored in the cache address corresponding to the same-process deployment type, and the smart contract to be deployed is initialized to obtain a successful smart contract deployment result.

[0117] The same-process deployment type refers to the type of deployment in the current process of the blockchain. The cache address refers to the address in the cache, which is the address pre-assigned by the blockchain node.

[0118] Specifically, the blockchain node determines that the deployment type corresponding to the smart contract to be deployed is the same-process deployment type, and obtains the corresponding cache address according to the same-process deployment type. Then the blockchain node stores the smart contract to be deployed in the cache address corresponding to the same-process deployment type, that is, stores the smart contract to be deployed in the smart contract cache pool in the blockchain node. Then the smart contract to be deployed is initialized, and the smart contract deployment success result is obtained.

[0119] In the above embodiment, when the deployment type is the same-process deployment type, the smart contract to be deployed is directly stored in the cache address corresponding to the same-process deployment type, and the smart contract to be deployed is initialized to obtain a successful result of the smart contract deployment, thereby improving the deployment efficiency of the smart contract.

[0120] In one embodiment, after S210, that is, after writing the result of successful deployment of the smart contract into the smart contract block, obtaining the target smart contract block, and writing the target smart contract block into the blockchain, the following steps are further included:

[0121] Get the execution request corresponding to the smart contract to be deployed, which carries the contract execution parameters; call the smart contract to be deployed from the cache address based on the execution request, and execute the smart contract to be deployed using the contract execution parameters to obtain the smart contract execution result corresponding to the execution request.

[0122] Among them, the contract execution parameters refer to the parameters required for executing the smart contract. For example, when the smart contract is a transaction smart contract, the contract execution parameters can be the transaction value, the transaction object information, etc. For example, when the smart contract is an invoice reimbursement smart contract, the contract execution parameters can be the reimbursement invoice information, the reimbursement object information, etc. The smart contract execution result refers to the output obtained after executing the smart contract using the contract execution parameters. For example, when the smart contract is a transaction smart contract, the smart contract execution result can be the execution result of the transaction completed. For example, when the smart contract is an invoice reimbursement smart contract, the smart contract execution result can be the execution result of the reimbursement completed.

[0123] Specifically, the blockchain node can obtain a transaction request that carries the contract execution parameters. At this time, the blockchain node responds to the transaction request and obtains the execution request corresponding to the smart contract to be deployed, which carries the contract execution parameters. Then, in response to the execution request, the smart contract to be deployed is called from the cache address, and the smart contract to be deployed is executed using the contract execution parameters to obtain the smart contract execution result corresponding to the execution request.

[0124] In the above embodiment, by obtaining the execution request corresponding to the smart contract to be deployed, the execution request carries the contract execution parameters, and then the smart contract to be deployed is called from the cache address based on the execution request, and the smart contract to be deployed is executed using the contract execution parameters, and the smart contract execution result corresponding to the execution request is obtained. That is, by calling the smart contract to be deployed from the cache address to execute the smart contract, the smart contract execution result can be quickly obtained, thereby improving the execution efficiency of the smart contract.

[0125] In one embodiment, S208, storing the smart contract to be deployed to the deployment address corresponding to the deployment address information, and initializing the smart contract to be deployed, and obtaining a successful result of the smart contract deployment, includes the steps of:

[0126] When the deployment type is a containerized deployment type, the smart contract to be deployed is stored in the mapping path address corresponding to the containerized deployment type, and the smart contract to be deployed is initialized to obtain a successful result of the smart contract deployment.

[0127] Among them, the containerized deployment type refers to the type of containerized deployment of smart contracts. Containerized deployment can refer to deployment in a virtual container, for example, the smart contract can be deployed in a virtual operating system. The mapping path address refers to the path address of the smart contract deployed in the blockchain node. The mapping path address is the path address in the blockchain node, that is, the path address that can be accessed by both the blockchain and the containerized deployed smart contract. When the virtual container in the blockchain node is started, the path address of the smart contract deployed in the blockchain node can be mapped to the virtual container.

[0128] Specifically, when the blockchain node determines that the deployment type is a containerized deployment type, it stores the smart contract to be deployed to the mapping path address corresponding to the containerized deployment type, and initializes the smart contract to be deployed, and obtains a successful result of smart contract deployment. Among them, the blockchain node deploys the smart contract in a virtual container, and the blockchain node and the virtual container can communicate directly, that is, through Unix Domin Socket (inter-process communication), which is used to realize communication between different processes on the same host.

[0129] In the above embodiment, the smart contract to be deployed is stored in the mapping path address corresponding to the containerized deployment type, and the smart contract to be deployed is initialized to obtain a successful smart contract deployment result. That is, the smart contract is deployed in a virtual container and logically separated from the blockchain, thereby improving the execution efficiency of the blockchain execution.

[0130] In one embodiment, after S210, that is, after writing the result of successful deployment of the smart contract into the smart contract block, obtaining the target smart contract block, and writing the target smart contract block into the blockchain, the following steps are further included:

[0131] Get the execution request corresponding to the smart contract to be deployed, which carries the contract execution parameters; call the smart contract to be deployed from the mapping path address based on the execution request, and use the contract execution parameters to execute the smart contract to be deployed, and get the smart contract execution result corresponding to the execution request.

[0132] Among them, the contract execution parameters refer to the parameters required for executing the smart contract. For example, when the smart contract is a transaction smart contract, the contract execution parameters can be the transaction value, the transaction object information, etc. For example, when the smart contract is an invoice reimbursement smart contract, the contract execution parameters can be the reimbursement invoice information, the reimbursement object information, etc. The smart contract execution result refers to the output obtained after executing the smart contract using the contract execution parameters. For example, when the smart contract is a transaction smart contract, the smart contract execution result can be the execution result of the transaction completed. For example, when the smart contract is an invoice reimbursement smart contract, the smart contract execution result can be the execution result of the reimbursement completed.

[0133] Specifically, the blockchain node can obtain a transaction request that carries the contract execution parameters, and respond to the transaction request to obtain the execution request corresponding to the smart contract to be deployed. At this time, the blockchain node starts the virtual container with the smart contract deployed, and then sends an execution request to the virtual container through inter-process communication, and the execution request carries the contract execution parameters. In response to the execution request, the virtual container calls the smart contract to be deployed from the mapping path address, and executes the smart contract to be deployed using the contract execution parameters, obtains the smart contract execution result corresponding to the execution request, and returns the smart contract execution result to the blockchain through inter-process communication.

[0134] In the above embodiment, by obtaining the execution request corresponding to the smart contract to be deployed, the execution request carries the contract execution parameters. Based on the execution request, the smart contract to be deployed is called from the mapping path address, and the smart contract to be deployed is executed using the contract execution parameters to obtain the smart contract execution result corresponding to the execution request. The smart contract to be deployed can be called from the mapping path address, and the smart contract to be deployed is executed using the contract execution parameters to obtain the smart contract execution result corresponding to the execution request, thereby improving the execution efficiency of the smart contract and saving the computing resources of the blockchain node.

[0135] In one embodiment, Figure 6 As shown, S208, the smart contract to be deployed is stored in the deployment address corresponding to the deployment address information, and the smart contract to be deployed is initialized to obtain a successful result of the smart contract deployment, including:

[0136] S602: When the deployment type is a remote deployment type, a contract deployment request is generated based on the smart contract to be deployed, and the contract deployment request is sent to the remote deployment end.

[0137] Among them, the remote deployment type refers to the type of deployment of smart contracts on the remote deployment end. The remote deployment end is used to represent a deployment device that is inconsistent with the blockchain node, that is, any device other than the blockchain node, which can be a server or a terminal. The contract deployment request refers to a request for deploying a smart contract, and the contract deployment request can carry the smart contract to be deployed.

[0138] Specifically, when the blockchain node determines that the deployment type is a remote deployment type, it generates a contract deployment request carrying the smart contract to be deployed. Then, the contract deployment request is sent to the remote deployment end through a pre-set communication protocol, wherein the contract deployment request can be sent to the remote deployment end through TCP (Transmission Control Protocol), which is a connection-oriented, reliable, byte stream-based transport layer communication protocol.

[0139] In one embodiment, the contract deployment request also carries blockchain node information. For example, the blockchain node information can be a blockchain node identifier. Then, when the remote deployment end obtains the contract deployment request, it first verifies whether the blockchain node identifier is in the whitelist. When the blockchain node identifier is in the whitelist, it verifies whether the blockchain node identifier is in the blacklist. When the blockchain node identifier is not in the blacklist, the blockchain node verification passes, and at this time, the remote deployment end can deploy the smart contract.

[0140] S604, obtaining a contract deployment request through the remote deployment end, and performing code vulnerability detection on the smart contract to be deployed based on the contract deployment request. When the code vulnerability detection of the smart contract to be deployed passes, obtaining the target path address corresponding to the smart contract to be deployed.

[0141] The target path address refers to the path address where the smart contract is deployed in the remote deployment terminal. The target path address can be pre-set.

[0142] Specifically, when the remote deployment end obtains the contract deployment request sent by the blockchain node, it first performs a digital signature verification on the contract deployment request. When the digital signature verification passes, it indicates that it is a contract deployment request sent by the blockchain node. At this time, the blockchain node is authenticated to verify whether it has the authority to perform remote deployment. When it has the authority to perform remote deployment, the remote deployment end performs code vulnerability detection on the smart contract to be deployed based on the contract deployment request. When the smart contract file to be deployed is a binary file, SCA can be used to perform software component vulnerability detection on the smart contract to be deployed. When the smart contract file to be deployed is not a binary file, SAST can be used to perform static code vulnerability detection on the smart contract file to be deployed. When the static code vulnerability detection passes, DAST can be used to perform dynamic code vulnerability detection on the smart contract file to be deployed. When the dynamic code vulnerability detection passes, IAST can be used to perform interactive application security detection on the smart contract file to be deployed. When the interactive application security detection passes, it is determined that the code vulnerability detection of the smart contract to be deployed passes. At this time, the remote deployment end obtains the target path address corresponding to the smart contract to be deployed, and the target path address can be pre-set and saved in the cache. The target path address can also be saved in the database.

[0143] S606, storing the target path address in the target cache through the remote deployment end, writing the smart contract to be deployed into the target path address, initializing the smart contract to be deployed, obtaining a successful result of the smart contract deployment, and returning the successful result of the smart contract deployment;

[0144] S608, obtain the smart contract deployment success result returned by the remote deployment end and return it.

[0145] Among them, the target cache refers to the cache in the remote deployment end that stores the smart contract deployment path address information.

[0146] Specifically, the remote deployment end first stores the target path address in the target cache, and then determines that the communication transmission with the blockchain node is TCP transmission, indicating that the smart contract to be deployed is deployed on the remote deployment end. At this time, the smart contract to be deployed is written into the target path address, and the smart contract to be deployed is initialized to obtain the result of successful deployment of the smart contract. Then the remote deployment end sends the result of successful deployment of the smart contract to the blockchain node via TCP transmission. Then the blockchain node obtains the result of successful deployment of the smart contract sent by the remote deployment end.

[0147] In one embodiment, when it is determined that the communication transmission with the blockchain node is transmission between the same processes, it indicates that the smart contract to be deployed is deployed in a virtual container. At this time, the smart contract to be deployed is deployed with a mapping path address, and the smart contract to be deployed is initialized to obtain a successful result of smart contract deployment.

[0148] In the above embodiment, the smart contract to be deployed is deployed through the remote deployment terminal, which realizes the separation of blockchain and smart contract, thereby saving the computing resources of blockchain nodes and improving the stability and security of blockchain operation.

[0149] In one embodiment, Figure 7 As shown, after S210, that is, after writing the successful result of the smart contract deployment into the smart contract block, obtaining the target smart contract block, and writing the target smart contract block into the blockchain, it also includes:

[0150] S702, obtaining an execution request corresponding to the smart contract to be deployed, where the execution request carries contract execution parameters.

[0151] S704, sending the execution request corresponding to the smart contract to be deployed to the remote deployment end, obtaining the target path address corresponding to the smart contract to be deployed from the target cache based on the execution request through the remote deployment end, and calling the smart contract to be deployed from the target path address.

[0152] Among them, contract execution parameters refer to the parameters required to execute smart contracts.

[0153] Specifically, the blockchain node obtains a transaction request, which needs to call the deployed smart contract. At this time, the blockchain node generates a corresponding execution request in response to the transaction request, which carries the contract execution parameters. Then, the execution request corresponding to the smart contract to be deployed is sent to the remote deployment end through the communication transmission protocol. The remote deployment end receives the execution request, obtains the target path address corresponding to the smart contract to be deployed from the target cache, and then calls the smart contract to be deployed from the target path address.

[0154] In one embodiment, the blockchain node encapsulates the contract execution parameters into the contract execution message body and sends the contract execution message body to the remote deployment end.

[0155] S706, executing the smart contract to be deployed using the contract execution parameters through the remote deployment end, obtaining the smart contract execution result corresponding to the execution request, and returning the smart contract execution result;

[0156] S708, obtaining the smart contract execution result returned by the remote deployment end.

[0157] Specifically, the remote deployment end executes the smart contract to be deployed with the contract execution parameters, obtains the smart contract execution result corresponding to the execution request, and then returns the smart contract execution result to the blockchain node through the communication protocol. The blockchain node obtains the smart contract execution result returned by the remote deployment end, generates a contract execution block based on the smart contract execution result and the contract execution parameters, and then writes the contract execution block into the blockchain.

[0158] In the above embodiment, the execution request corresponding to the smart contract to be deployed is sent to the remote deployment end, and the remote deployment end obtains the target path address corresponding to the smart contract to be deployed from the target cache based on the execution request, and calls the smart contract to be deployed from the target path address, and executes the smart contract to be deployed using the contract execution parameters, obtains the smart contract execution result corresponding to the execution request, and returns the smart contract execution result. Finally, the smart contract execution result returned by the remote deployment end is obtained, so that the smart contract can be executed on the remote deployment end, avoiding the execution of the smart contract in the blockchain node, thereby saving the computing resources of the blockchain node, and ensuring the efficient execution of the blockchain.

[0159] In a specific embodiment, Figure 8As shown, a flowchart of blockchain smart contract deployment is provided. Specifically, the blockchain node receives a transaction request for installing a smart contract, and then verifies the authority and legitimacy of the transaction. When the authority and legitimacy verification fails, a failure result is returned, and the transaction request and the corresponding failure result are written into the blockchain in the form of a block. When the authority and legitimacy verification pass, the blockchain node puts the transaction into the transaction pool of the blockchain. The blockchain node selects transaction requests from the transaction pool to package and generate blocks, wherein a transaction request for installing a smart contract is selected, and then the transaction request is executed. When executing the transaction request for installing a smart contract, a smart contract security audit is first performed on the smart contract, that is, a code vulnerability detection is performed. The blockchain node first determines whether the smart contract file is a binary code file. When it is a binary code file, a code vulnerability detection is performed through SCA to obtain a code vulnerability detection result, which includes a code vulnerability detection pass and a code vulnerability detection failure. When the smart contract file is not a binary code file, SAST is used to detect code vulnerabilities and obtain the code vulnerability detection results. When the code vulnerability detection results of SAST are passed, DAST is used to detect code vulnerabilities and obtain the code vulnerability detection results. When the code vulnerability detection results of DAST are passed, IAST is used to detect code vulnerabilities and obtain the code vulnerability detection results. When the code vulnerability detection results of IAST are passed, it means that the smart contract code vulnerability detection has passed. When any of the tests fails, the blockchain node returns a failure result and then determines whether the transaction is successfully executed. The blockchain node returns a failure result, indicating that the transaction execution failed. At this time, the transaction request is marked as failed. Then the failed transaction results and the smart contract are written into the block for record. Then, when it is determined that all transactions in the block have been executed, the block is written into the blockchain, that is, the blockchain status data is updated, and the block is appended to the blockchain ledger for storage.

[0160] When the code vulnerability detection passes, the blockchain node determines whether it is a smart contract transaction request of the same process virtual machine. If it is a smart contract transaction request of the same process, the smart contract can be directly stored in the contract cache pool in the blockchain node and the correct result is returned. When it is not a smart contract transaction request of the same process, the blockchain node determines whether it is containerized deployment. If it is containerized deployment, it means that the smart contract is deployed in the virtual container. If it is not containerized deployment, it means that the smart contract is deployed on the remote deployment end. When it is containerized deployment, the smart contract is first stored in the mapping path, which can directly map the internal path of the container, and the blockchain node then sends the contract creation message body to the container deployment end. When it is remote deployment, the blockchain node encapsulates the smart contract file into the contract creation message body, and then sends the contract creation message body to the remote deployment end. Among them, the remote deployment end and the container deployment end are both independently deployed, and the independent deployment means that it is deployed independently of the blockchain, that is, it is not deployed in the blockchain.

[0161] When deploying independently, first obtain the contract deployment request, which carries the contract creation message body, and then verify the contract deployment request, that is, verify whether the digital signature is consistent. When the digital signature verification passes, verify whether the blockchain node is in the whitelist and whether the blockchain node is not in the blacklist. When the blockchain node is verified, the smart contract is audited for contract security. That is, the smart contract can be tested for code vulnerabilities through SCA. When the test passes, the deployment path of the smart contract is stored in the contract path cache pool, and then it is determined whether it is TCP communication transmission. When it is TCP communication transmission, the smart contract file is written to the deployment path corresponding to the disk. When it is not TCP communication transmission, it means that it is inter-process communication, that is, containerized deployment. At this time, the smart contract has been stored in the mapping path and does not need to be stored again. Then return the correct result to the blockchain node. Among them, when any verification fails, an error result is returned to the blockchain node.

[0162] The blockchain node obtains the deployment result returned by the independent deployment, which can be an error result or a correct result. Then it determines whether the transaction request is executed successfully. If it is a correct result, the transaction request is marked as executed successfully. If it is an error result, the transaction request is marked as executed failed. Then the transaction result and the smart contract are written into the block for record. Then, when it is determined that all transactions in the block have been executed, the block is written into the blockchain, that is, the blockchain status data is updated, and the block is appended to the blockchain ledger for storage, thereby completing the deployment of the blockchain smart contract, thereby improving the security of the blockchain smart contract deployment, and independent deployment can save the computing resources of the blockchain node, so that the blockchain node can run efficiently and stably.

[0163] In one embodiment, Fig. 9 As shown, the blockchain smart contract deployment method also includes:

[0164] S902, obtaining a target blockchain transaction request, where the target blockchain transaction request carries an updated smart contract.

[0165] S904, responding to the target blockchain transaction request, generating a smart contract update block based on the updated smart contract, and performing code vulnerability detection on the updated smart contract.

[0166] The updated smart contract refers to the updated smart contract, which replaces the deployed smart contract.

[0167] Specifically, the blockchain node can obtain the target blockchain transaction request from the terminal, and then the blockchain node can perform a legitimacy check on the target blockchain transaction request. When the legitimacy check passes, the target blockchain transaction request is parsed to obtain an updated smart contract. Then the blockchain node responds to the target blockchain transaction request and uses the updated smart contract to generate a smart contract update block, and executes the target blockchain transaction request, that is, updates the smart contract. At this time, the blockchain node first performs a code vulnerability detection on the updated smart contract, which may include software component vulnerability detection, static code vulnerability detection, dynamic code vulnerability detection, and interactive application security detection. When any code vulnerability detection fails, it is determined that the code vulnerability detection on the updated smart contract has failed. When all code vulnerability detections pass, it is determined that the code vulnerability detection on the updated smart contract has passed.

[0168] S906, when the code vulnerability detection of the updated smart contract passes, the deployment address corresponding to the updated smart contract is obtained based on the code language type corresponding to the updated smart contract.

[0169] S908, replace the historical smart contract stored in the deployment address with the updated smart contract, initialize the updated smart contract, and obtain a successful result of the smart contract update.

[0170] S910, write the successful result of the smart contract update into the smart contract update block, obtain the target smart contract update block, and write the target smart contract update block into the blockchain.

[0171] Among them, the historical smart contract refers to the smart contract that has been stored in the deployment address, which is a smart contract that has been deployed and needs to be updated. The target smart contract update block refers to the block where the updated smart contract and the corresponding smart contract update success result are written.

[0172] Specifically, when the blockchain node passes the code vulnerability detection for the updated smart contract, the deployment address corresponding to the updated smart contract is obtained based on the code language type corresponding to the updated smart contract. In one embodiment, the historical smart contract corresponding to the same identifier can also be obtained according to the identifier of the updated smart contract, and then the deployment address of the historical smart contract is obtained. Then the historical smart contract stored at the deployment address is replaced with the updated smart contract, and the updated smart contract is initialized to obtain the successful result of the smart contract update. Finally, the successful result of the smart contract update is written into the smart contract update block, the target smart contract update block is obtained, and the target smart contract update block is written into the blockchain. When updating a smart contract, it can be implemented through the steps of the blockchain smart contract deployment method. The difference is that when writing a smart contract to the deployment address, the historically deployed smart contract is replaced with the updated smart contract, and the other steps remain the same.

[0173] In the above embodiment, by obtaining the target blockchain transaction request, a smart contract update block is generated based on the updated smart contract in response to the target blockchain transaction request, and the updated smart contract is tested for code vulnerabilities. When the code vulnerability test for the updated smart contract passes, the deployment address corresponding to the updated smart contract is obtained based on the code language type corresponding to the updated smart contract; the historical smart contract stored in the deployment address is replaced with the updated smart contract, and the updated smart contract is initialized to obtain a successful smart contract update result; the successful smart contract update result is written into the smart contract update block to obtain the target smart contract update block, and the target smart contract update block is written into the blockchain, so that the smart contract can be updated when the code vulnerability test for the updated smart contract passes, thereby improving the security of the smart contract update.

[0174] In a specific embodiment, Fig.10 As shown, a flowchart of a blockchain smart contract update is provided. Specifically:

[0175] The blockchain node receives the transaction request for updating the smart contract, and then verifies the authority and legitimacy of the transaction request for updating the smart contract. When the authority and legitimacy verification fails, a failure result is returned, and the transaction request and the corresponding failure result are written into the blockchain in the form of a block. When the authority and legitimacy verification pass, the blockchain node puts the transaction request for updating the smart contract into the transaction pool of the blockchain. The blockchain node selects transaction requests from the transaction pool to package and generate blocks, in which the transaction request for updating the smart contract is selected, and then the transaction request for updating the smart contract is executed. When executing the transaction request for updating the smart contract, a smart contract security audit is first performed on the updated smart contract, that is, code vulnerability detection is performed. The blockchain node first determines whether the updated smart contract file is a binary code file. When the updated smart contract file is a binary code file, a code vulnerability detection is performed through SCA to obtain a code vulnerability detection result, which includes a code vulnerability detection pass and a code vulnerability detection fail. When the updated smart contract file is not a binary code file, SAST is used to detect code vulnerabilities and obtain the code vulnerability detection results. When the code vulnerability detection results of SAST are passed, DAST is used to detect code vulnerabilities and obtain the code vulnerability detection results. When the code vulnerability detection results of DAST are passed, IAST is used to detect code vulnerabilities and obtain the code vulnerability detection results. When the code vulnerability detection results of IAST are passed, it means that the smart contract code vulnerability detection has passed. When any of the tests fails, the blockchain node returns a failure result, and then determines whether the transaction request to update the smart contract is executed successfully. When the blockchain node returns a failure result, it means that the transaction execution failed. At this time, the transaction request to update the smart contract is marked as failed. Then the failed transaction results and the smart contract are written into the block for record. Then, when it is determined that all transactions in the block have been executed, the block is written into the blockchain, that is, the blockchain status data is updated, and the block is appended to the blockchain ledger for storage.

[0176] When the code vulnerability detection passes, the blockchain node determines whether it is a smart contract transaction request of the same process virtual machine. When it is a smart contract transaction request of the same process, the historical smart contract stored in the contract cache pool is replaced with an updated smart contract, and the correct result is returned. When it is not an updated smart contract transaction request of the same process, the blockchain node determines whether it is a containerized deployment. If it is a containerized deployment, it means that the updated smart contract is deployed in the virtual container. If it is not a containerized deployment, it means that the updated smart contract is deployed on the remote deployment end. When it is a containerized deployment, the updated smart contract is first stored in the mapping path, which can directly map the internal path of the container, and the blockchain node then sends the contract update message body to the container deployment end. When it is a remote deployment, the blockchain node encapsulates the updated smart contract file into the contract update message body, and then sends the contract update message body to the remote deployment end. Among them, the remote deployment end and the container deployment end are both independently deployed, and the independent deployment means that it is deployed independently of the blockchain, that is, it is not deployed in the blockchain, which can include logical independence (containerized deployment) and device (remote deployment) independence.

[0177] When deploying independently, the contract deployment request is first obtained. The contract deployment request carries the contract update message body. Then the contract deployment request is signed, that is, the digital signature is verified to be consistent. When the digital signature verification is passed, the blockchain node is verified to be in the whitelist and the blockchain node is not in the blacklist. When the blockchain node is verified, the contract security audit is performed on the updated smart contract. That is, the smart contract can be tested for code vulnerabilities through SCA. When the test is passed, the deployment path of the updated smart contract is stored in the contract path cache pool, and then it is determined whether it is TCP communication transmission. When it is TCP communication transmission, the historical smart contract stored in the deployment path is replaced with the updated smart contract, and the updated smart contract is initialized. When it is not TCP communication transmission, it means that it is inter-process communication, that is, containerized deployment. At this time, the updated smart contract has been stored in the mapping path and does not need to be stored again. Then the correct result is returned to the blockchain node. Among them, when any verification fails, an error result is returned to the blockchain node.

[0178] The blockchain node obtains the deployment result returned by the independent deployment, which can be an error result or a correct result. Then it determines whether the transaction request to update the smart contract is executed successfully. If it is a correct result, the transaction request to update the smart contract is marked as executed successfully. If it is an error result, the transaction request to update the smart contract is marked as failed. Then the transaction result and the updated smart contract are written into the block for record. Then when all transactions in the block are executed, the block is written into the blockchain, that is, the blockchain status data is updated, and the block is appended to the blockchain ledger for storage, thereby completing the update of the blockchain smart contract, thereby improving the security of the blockchain smart contract update, and independent deployment can save the computing resources of the blockchain node, so that the blockchain node can run efficiently and stably.

[0179] In a specific embodiment, Fig.11 As shown, a flowchart of a blockchain smart contract deployment method is provided, which specifically includes the following steps:

[0180] S1102, receiving a blockchain transaction request, the blockchain transaction request carries the smart contract to be deployed, and responding to the blockchain transaction request to generate a smart contract block based on the smart contract to be deployed.

[0181] S1104, obtaining the code state corresponding to the smart contract to be deployed. When the code state is a binary code state, performing vulnerability detection on the smart contract to be deployed based on the software component vulnerability detection information corresponding to the binary code state.

[0182] S1106: When the code state is a non-binary code state, static code vulnerability detection is performed on the smart contract to be deployed based on static code vulnerability detection information corresponding to the non-binary code state.

[0183] S1108, when the static code vulnerability detection passes, dynamic code vulnerability detection is performed on the smart contract to be deployed based on the dynamic code vulnerability detection information corresponding to the non-binary code state.

[0184] S1110, when the dynamic code vulnerability detection passes, an interactive application security detection is performed on the smart contract to be deployed based on the interactive application security detection information corresponding to the non-binary code state. When the interactive application security detection passes, it is determined that the code vulnerability detection of the smart contract to be deployed has passed.

[0185] S1112, when the code vulnerability detection of the smart contract to be deployed passes, the deployment type corresponding to the smart contract to be deployed is determined based on the code language type corresponding to the smart contract to be deployed, and the deployment address information corresponding to the smart contract to be deployed is obtained based on the deployment type.

[0186] S1114, store the smart contract to be deployed to the deployment address corresponding to the deployment address information, initialize the smart contract to be deployed, obtain the successful result of the smart contract deployment, write the successful result of the smart contract deployment into the smart contract block, obtain the target smart contract block, and write the target smart contract block into the blockchain.

[0187] S1116, when the code vulnerability detection of the smart contract to be deployed fails, the smart contract deployment failure result is obtained, the smart contract deployment failure result is written into the smart contract block, the current smart contract block is obtained, and the current smart contract block is written into the blockchain.

[0188] In the above embodiment, when receiving a blockchain transaction request, a code vulnerability check is performed on the smart contract to be deployed. Only when the code vulnerability check of the smart contract to be deployed passes, the smart contract to be deployed is deployed, and the target smart contract block is written into the blockchain, thereby avoiding the deployment of a smart contract with a vulnerability into the blockchain, thereby improving the security of the smart contract deployment.

[0189] In a specific embodiment, Fig.12 As shown, a schematic diagram of the architecture of blockchain smart contract deployment is provided. Specifically: the architecture of the blockchain smart contract deployment includes a blockchain node and an independently deployed contract engine, and the independently deployed contract engine is in other non-blockchain node devices.

[0190] Among them, the blockchain node is used for blockchain business processing such as block generation, consensus, storage, etc. The blockchain node includes a network module, which is a module for blockchain to communicate with the outside, including communication with outsourced computing service providers, communication with user clients and communication with blockchain nodes. The blockchain node includes a consensus module, which is a module for consensus on blocks between blockchain nodes, including master node execution blocks, verification nodes verification blocks, and multiple rounds of consensus to reach an agreement. The blockchain node includes an authentication module, which is a module for storing digital certificates and verifying the legitimacy of digital certificates and transactions. The authentication module stores blockchain node certificates, and the digital certificates of the blockchain nodes are used for identity mutual recognition between blockchain nodes. The authentication module stores blockchain user certificates, which are certificates of users in the blockchain organization, used to identify whether the user is a legitimate blockchain user. The authentication module stores contract engine certificates and black and white lists. The authentication module saves all contract engine certificates and contract engine black and white lists, and is used to record the independently deployed contract engines that are allowed to be deployed, and the independently deployed contract engines need to be in the white list, and the independently deployed contract engines are not in the black list. The blockchain node also includes a storage module, which is a module for storing state data and account data of the blockchain. Every time a new block is generated, the storage module will be updated; the state data storage module included in the storage module can store all state data (latest updated data). The blockchain account storage module included in the storage module can store new block information in an appended manner. The blockchain node also includes a contract security audit module, which is a module for auditing the security of smart contracts. Through the contract security audit module, SAST, DAST, IAST and SCA can be used to detect code vulnerabilities in smart contract codes. The blockchain node also includes a virtual machine module, which is the core module for smart contract transaction calculations and is in the same process as the blockchain (usually EVM, WASM and other virtual machines). Among them, the contract cache pool is a pool for caching smart contract files, and smart contracts can be called directly from the contract cache pool to avoid repeatedly obtaining contract files from storage. The virtual machine transaction scheduling module is used to schedule all virtual machine transactions to different contract threads for execution. The contract thread is the entity that executes the transaction, and the runtime state of the smart contract and the outsourced calculation are initiated by this module.

[0191] Among them, the independent deployment contract engine service performs contract transaction calculations independently of the blockchain. It can be deployed locally or across machines. It mainly includes the following modules: The network module is used to communicate with the blockchain, obtain task execution applications from the blockchain and return execution results. The authentication module is a module for storing certificates, black and white lists, and verifying the legitimacy of certificates and transactions. Among them, the blockchain node certificate, the certificate of the blockchain node, is used for mutual recognition of identity between nodes. The blockchain node black / white list is used to record blockchain nodes that are allowed to communicate. The blockchain node needs to be in the white list and not in the black list. The transaction process scheduling module is a task scheduling module for transactions and processes. Among them, the transaction scheduling module is used to schedule transactions to the corresponding contract group and apply for processes for processing. The process scheduling module is used to allocate process resources and manage the entire life cycle of the process. The contract path cache pool is used to cache the contract path. When the contract process needs to be started, the process under the path can be directly started. The contract security audit module detects vulnerabilities in smart contract code through SCA, SAST, DAST and IAST. The execution module is a module for executing contract transactions. The contract process is the runtime entity of the smart contract file and the process that actually executes the transaction. The contract engine will start multiple contract processes to maximize the operating efficiency of the transaction.

[0192] Through the cooperation of various modules in the architecture of blockchain smart contract deployment, code vulnerability detection can be performed on smart contracts that need to be deployed or updated, that is, code vulnerability detection methods such as SAST, DAST, IAST and SCA can be used to scan and audit contract files for vulnerabilities, thereby avoiding the installation of code files with vulnerabilities into the blockchain and improving the security of the blockchain.

[0193] In a specific embodiment, the blockchain smart contract is applied in a transaction scenario, specifically:

[0194] The blockchain node receives a blockchain transaction request, which carries a transaction smart contract to be deployed. The transaction smart contract is used to conduct transactions in the blockchain. The blockchain node generates a smart contract block based on the transaction smart contract in response to the blockchain transaction request, and obtains the code status corresponding to the transaction smart contract. Based on the code status, the corresponding vulnerability detection information is obtained, and the code vulnerability detection information is used to detect the code vulnerability of the transaction smart contract. When the code vulnerability detection of the transaction smart contract passes, the deployment address information corresponding to the transaction smart contract is obtained based on the code language type corresponding to the transaction smart contract; the transaction smart contract is stored in the deployment address corresponding to the deployment address information, and the transaction smart contract is initialized to obtain the result of successful deployment of the smart contract. The result of successful deployment of the smart contract is written into the smart contract block, the target smart contract block is obtained, and the target smart contract block is written into the blockchain. Then, when the blockchain node obtains the transaction request, it parses the transaction request to obtain the transaction amount and transaction object carried by the transaction request. The blockchain node calls the corresponding transaction smart contract from the deployment address, and then uses the transaction amount and transaction object to execute through the transaction smart contract to obtain the execution result of the transaction smart contract, including the remaining amount after the transaction, the amount of the transaction object after the transaction, etc., and then writes the transaction data corresponding to the transaction request into the blockchain to complete the transaction. That is, code vulnerability detection is performed when deploying the transaction smart contract to avoid deploying vulnerable transaction smart contracts into the blockchain, thereby improving the security of blockchain transactions.

[0195] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0196] Based on the same inventive concept, the embodiment of the present application also provides a blockchain smart contract deployment device for implementing the blockchain smart contract deployment method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more blockchain smart contract deployment device embodiments provided below can refer to the limitations of the blockchain smart contract deployment method above, and will not be repeated here.

[0197] In one embodiment, Fig.13 As shown, a blockchain smart contract deployment device 1300 is provided, including: a request receiving module 1302, a state acquisition module 1304, a code detection module 1306, a deployment module 1308 and a block writing module 1310, wherein:

[0198] A request receiving module 1302 is used to receive a blockchain transaction request, where the blockchain transaction request carries a smart contract to be deployed;

[0199] The state acquisition module 1304 is used to generate a smart contract block based on the smart contract to be deployed in response to the blockchain transaction request, and obtain the code state corresponding to the smart contract to be deployed; the code detection module 1306 is used to obtain the corresponding vulnerability detection information based on the code state, and use the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed; the deployment module 1308 is used to deploy the smart contract to be deployed when the code vulnerability detection of the smart contract to be deployed passes, and obtain a successful deployment result of the smart contract;

[0200] The block writing module 1310 is used to write the successful result of the smart contract deployment into the smart contract block, obtain the target smart contract block, and write the target smart contract block into the blockchain.

[0201] In one embodiment, the code detection module 1304 is also used to perform vulnerability detection on the smart contract to be deployed based on the software component vulnerability detection information corresponding to the binary code state when the code state is a binary code state; and to perform vulnerability detection on the smart contract to be deployed based on each preset vulnerability detection information corresponding to the non-binary code state when the code state is a non-binary code state.

[0202] In one embodiment, the code detection module 1304 is also used to perform static code vulnerability detection on the smart contract to be deployed based on the static code vulnerability detection information corresponding to the non-binary code state; when the static code vulnerability detection passes, the dynamic code vulnerability detection is performed on the smart contract to be deployed based on the dynamic code vulnerability detection information corresponding to the non-binary code state; when the dynamic code vulnerability detection passes, the interactive application security detection is performed on the smart contract to be deployed based on the interactive application security detection information corresponding to the non-binary code state, and when the interactive application security detection passes, it is determined that the code vulnerability detection for the smart contract to be deployed has passed.

[0203] In one embodiment, the code detection module 1304 is also used to obtain the target signature corresponding to the smart contract to be deployed, which is obtained by digitally signing the smart contract to be deployed after passing the code vulnerability detection; calculate the contract hash corresponding to the smart contract to be deployed, and digitally sign the contract hash to obtain the contract signature; determine the code vulnerability detection result of the smart contract to be deployed based on the consistency of the contract signature and the target signature.

[0204] In one embodiment, the blockchain smart contract deployment device 1300 further includes:

[0205] The deployment failure module is used to obtain the smart contract deployment failure result when the code vulnerability detection of the smart contract to be deployed fails; write the smart contract deployment failure result into the smart contract block, obtain the current smart contract block, and write the current smart contract block into the blockchain.

[0206] In one embodiment, the information acquisition module 1306 is also used to determine the deployment type corresponding to the smart contract to be deployed based on the code language type corresponding to the smart contract to be deployed, obtain the deployment address information corresponding to the smart contract to be deployed based on the deployment type, store the smart contract to be deployed to the deployment address corresponding to the deployment address information, and initialize the smart contract to be deployed to obtain a successful deployment result of the smart contract.

[0207] In one embodiment, the deployment module 1308 is also used to store the smart contract to be deployed to the cache address corresponding to the same-process deployment type when the deployment type is the same-process deployment type, and initialize the smart contract to be deployed to obtain a successful smart contract deployment result.

[0208] In one embodiment, the blockchain smart contract deployment device 1300 further includes:

[0209] The cache execution module is used to obtain the execution request corresponding to the smart contract to be deployed, and the execution request carries the contract execution parameters;

[0210] Based on the execution request, the smart contract to be deployed is called from the cache address, and the smart contract to be deployed is executed using the contract execution parameters to obtain the smart contract execution result corresponding to the execution request.

[0211] In one embodiment, the deployment module 1308 is also used to store the smart contract to be deployed to the mapping path address corresponding to the containerized deployment type when the deployment type is a containerized deployment type, and initialize the smart contract to be deployed to obtain a successful smart contract deployment result.

[0212] In one embodiment, the blockchain smart contract deployment device 1300 further includes:

[0213] The mapping execution module is used to obtain the execution request corresponding to the smart contract to be deployed, which carries the contract execution parameters; based on the execution request, the smart contract to be deployed is called from the mapping path address, and the smart contract to be deployed is executed using the contract execution parameters to obtain the smart contract execution result corresponding to the execution request.

[0214] In one embodiment, the deployment module 1308 is also used to generate a contract deployment request based on the smart contract to be deployed when the deployment type is a remote deployment type, and send the contract deployment request to the remote deployment end; obtain the contract deployment request through the remote deployment end, and perform code vulnerability detection on the smart contract to be deployed based on the contract deployment request, and when the code vulnerability detection of the smart contract to be deployed passes, obtain the target path address corresponding to the smart contract to be deployed; store the target path address in the target cache through the remote deployment end, write the smart contract to be deployed into the target path address, and initialize the smart contract to be deployed, obtain the smart contract deployment success result, and return the smart contract deployment success result; obtain the smart contract deployment success result returned by the remote deployment end and return it.

[0215] In one embodiment, the blockchain smart contract deployment device 1300 further includes:

[0216] The remote execution module is used to obtain the execution request corresponding to the smart contract to be deployed, which carries the contract execution parameters; send the execution request corresponding to the smart contract to be deployed to the remote deployment end, obtain the target path address corresponding to the smart contract to be deployed from the target cache based on the execution request through the remote deployment end, and call the smart contract to be deployed from the target path address; execute the smart contract to be deployed using the contract execution parameters through the remote deployment end, obtain the smart contract execution result corresponding to the execution request, and return the smart contract execution result; obtain the smart contract execution result returned by the remote deployment end.

[0217] In one embodiment, the blockchain smart contract deployment device 1300 further includes:

[0218] The update module is used to obtain a target blockchain transaction request, which carries an updated smart contract; in response to the target blockchain transaction request, a smart contract update block is generated based on the updated smart contract, and a code vulnerability detection is performed on the updated smart contract; when the code vulnerability detection of the updated smart contract passes, the deployment address corresponding to the updated smart contract is obtained based on the code language type corresponding to the updated smart contract; the historical smart contract stored in the deployment address is replaced with the updated smart contract, and the updated smart contract is initialized to obtain a successful smart contract update result; the successful smart contract update result is written into the smart contract update block, the target smart contract update block is obtained, and the target smart contract update block is written into the blockchain.

[0219] Each module in the above-mentioned blockchain smart contract deployment device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of each of the above modules.

[0220] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig.14 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store smart contract data and blockchain data, etc. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a blockchain smart contract deployment method is implemented.

[0221] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Fig.15As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless method can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a blockchain smart contract deployment method is implemented. The display unit of the computer device is used to form a visually visible image, and can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covered on the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse, etc.

[0222] Those skilled in the art will understand that Fig.14 or Fig.15 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0223] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0224] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0225] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0226] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0227] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0228] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0229] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A blockchain smart contract deployment method, characterized in that: The method comprises: Receiving a blockchain transaction request, wherein the blockchain transaction request carries a smart contract to be deployed; In response to the blockchain transaction request, a smart contract block is generated based on the smart contract to be deployed, and a code status corresponding to the smart contract to be deployed is obtained; Acquire corresponding vulnerability detection information based on the code status, and use the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed; When the code vulnerability detection of the smart contract to be deployed passes, the smart contract to be deployed is deployed to obtain a successful smart contract deployment result; The successful deployment result of the smart contract is written into the smart contract block, a target smart contract block is obtained, and the target smart contract block is written into the blockchain.

2. The method according to claim 1, characterized in that The acquiring corresponding vulnerability detection information based on the code state, and using the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed, includes: When the code state is a binary code state, performing vulnerability detection on the to-be-deployed smart contract based on the software component vulnerability detection information corresponding to the binary code state; When the code state is a non-binary code state, vulnerability detection is performed on the smart contract to be deployed based on each preset vulnerability detection information corresponding to the non-binary code state.

3. The method according to claim 1, characterized in that The performing vulnerability detection on the smart contract to be deployed based on each preset vulnerability detection information corresponding to the non-binary code state includes: Performing static code vulnerability detection on the smart contract to be deployed based on the static code vulnerability detection information corresponding to the non-binary code state; When the static code vulnerability detection passes, performing dynamic code vulnerability detection on the smart contract to be deployed based on the dynamic code vulnerability detection information corresponding to the non-binary code state; When the dynamic code vulnerability detection passes, an interactive application security detection is performed on the smart contract to be deployed based on the interactive application security detection information corresponding to the non-binary code state. When the interactive application security detection passes, it is determined that the code vulnerability detection of the smart contract to be deployed has passed.

4. The method according to claim 1, characterized in that The method further comprises: Obtaining a target signature corresponding to the smart contract to be deployed, where the target signature is obtained by digitally signing the smart contract to be deployed after passing code vulnerability detection; Calculate the contract hash corresponding to the smart contract to be deployed, and digitally sign the contract hash to obtain a contract signature; Determine the vulnerability detection result of the smart contract code to be deployed based on the consistency of the contract signature and the target signature.

5. The method according to claim 1, characterized in that After generating a smart contract block based on the smart contract to be deployed in response to the blockchain transaction request and performing code vulnerability detection on the smart contract to be deployed, the method further includes: When the code vulnerability detection of the smart contract to be deployed fails, a smart contract deployment failure result is obtained; The failure result of the smart contract deployment is written into the smart contract block to obtain the current smart contract block, and the current smart contract block is written into the blockchain.

6. The method according to claim 1, characterized in that The step of deploying the smart contract to be deployed and obtaining a smart contract deployment result includes: Determine the deployment type corresponding to the smart contract to be deployed based on the code language type corresponding to the smart contract to be deployed, and obtain deployment address information corresponding to the smart contract to be deployed based on the deployment type; The smart contract to be deployed is stored in the deployment address corresponding to the deployment address information, and the smart contract to be deployed is initialized to obtain a successful deployment result of the smart contract.

7. The method according to claim 6, characterized in that The step of storing the smart contract to be deployed to the deployment address corresponding to the deployment address information, initializing the smart contract to be deployed, and obtaining a successful result of smart contract deployment includes: When the deployment type is the same-process deployment type, the smart contract to be deployed is stored in a cache address corresponding to the same-process deployment type, and the smart contract to be deployed is initialized to obtain a successful smart contract deployment result.

8. The method according to claim 7, characterized in that After writing the successful result of the smart contract deployment into the smart contract block to obtain the target smart contract block, and writing the target smart contract block into the blockchain, the method further includes: Obtaining an execution request corresponding to the smart contract to be deployed, wherein the execution request carries contract execution parameters; Based on the execution request, the smart contract to be deployed is called from the cache address, and the smart contract to be deployed is executed using the contract execution parameters to obtain a smart contract execution result corresponding to the execution request.

9. The method according to claim 6, characterized in that The step of storing the smart contract to be deployed to the deployment address corresponding to the deployment address information, initializing the smart contract to be deployed, and obtaining a successful result of smart contract deployment includes: When the deployment type is a containerized deployment type, the smart contract to be deployed is stored in a mapping path address corresponding to the containerized deployment type, and the smart contract to be deployed is initialized to obtain a successful smart contract deployment result.

10. The method according to claim 9, characterized in that After writing the successful result of the smart contract deployment into the smart contract block to obtain the target smart contract block, and writing the target smart contract block into the blockchain, the method further includes: Obtaining an execution request corresponding to the smart contract to be deployed, wherein the execution request carries contract execution parameters; Based on the execution request, the smart contract to be deployed is called from the mapping path address, and the smart contract to be deployed is executed using the contract execution parameters to obtain the smart contract execution result corresponding to the execution request.

11. The method according to claim 6, characterized in that The step of storing the smart contract to be deployed to the deployment address corresponding to the deployment address information, initializing the smart contract to be deployed, and obtaining a successful result of smart contract deployment includes: When the deployment type is a remote deployment type, generating a contract deployment request based on the smart contract to be deployed, and sending the contract deployment request to a remote deployment end; Obtain the contract deployment request through the remote deployment end, and perform code vulnerability detection on the smart contract to be deployed based on the contract deployment request, and when the code vulnerability detection on the smart contract to be deployed passes, obtain the target path address corresponding to the smart contract to be deployed; The target path address is stored in the target cache through the remote deployment end, the smart contract to be deployed is written into the target path address, and the smart contract to be deployed is initialized to obtain a successful smart contract deployment result, and the successful smart contract deployment result is returned; The smart contract deployment success result returned by the remote deployment end is obtained and returned.

12. The method according to claim 11, characterized in that After writing the successful result of the smart contract deployment into the smart contract block to obtain the target smart contract block, and writing the target smart contract block into the blockchain, the method further includes: Obtaining an execution request corresponding to the smart contract to be deployed, wherein the execution request carries contract execution parameters; Sending an execution request corresponding to the smart contract to be deployed to the remote deployment end, obtaining the target path address corresponding to the smart contract to be deployed from the target cache through the remote deployment end based on the execution request, and calling the smart contract to be deployed from the target path address; Execute the smart contract to be deployed by the remote deployment end using the contract execution parameters, obtain the smart contract execution result corresponding to the execution request, and return the smart contract execution result; Obtain the smart contract execution result returned by the remote deployment end.

13. The method according to claim 1, characterized in that The method further comprises: Obtaining a target blockchain transaction request, wherein the target blockchain transaction request carries an updated smart contract; In response to the target blockchain transaction request, a smart contract update block is generated based on the updated smart contract, and code vulnerability detection is performed on the updated smart contract; When the code vulnerability detection of the updated smart contract passes, obtaining the deployment address corresponding to the updated smart contract based on the code language type corresponding to the updated smart contract; Replace the historical smart contract stored in the deployment address with the updated smart contract, initialize the updated smart contract, and obtain a successful smart contract update result; The successful result of the smart contract update is written into the smart contract update block to obtain the target smart contract update block, and the target smart contract update block is written into the blockchain.

14. A blockchain smart contract deployment device, characterized in that: The device comprises: A request receiving module, used to receive a blockchain transaction request, wherein the blockchain transaction request carries a smart contract to be deployed; A status acquisition module, used to generate a smart contract block based on the smart contract to be deployed in response to the blockchain transaction request, and obtain the code status corresponding to the smart contract to be deployed; A code detection module, used to obtain corresponding vulnerability detection information based on the code status, and use the vulnerability detection information to perform code vulnerability detection on the smart contract to be deployed; A deployment module, used to deploy the smart contract to be deployed when the code vulnerability detection of the smart contract to be deployed passes, and obtain a successful deployment result of the smart contract; The block writing module is used to write the successful result of the smart contract deployment into the smart contract block, obtain the target smart contract block, and write the target smart contract block into the blockchain.

15. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 13 are implemented.

16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 13 are implemented.

17. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 13 are implemented.