WO2020233092A1 - 智能合约调用方法、装置、设备和存储介质 - Google Patents

智能合约调用方法、装置、设备和存储介质 Download PDF

Info

Publication number
WO2020233092A1
WO2020233092A1 PCT/CN2019/122856 CN2019122856W WO2020233092A1 WO 2020233092 A1 WO2020233092 A1 WO 2020233092A1 CN 2019122856 W CN2019122856 W CN 2019122856W WO 2020233092 A1 WO2020233092 A1 WO 2020233092A1
Authority
WO
WIPO (PCT)
Prior art keywords
smart contract
compilation
file
dynamic
script
Prior art date
Application number
PCT/CN2019/122856
Other languages
English (en)
French (fr)
Inventor
陈沐豪
褚镇飞
Original Assignee
深圳壹账通智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2020233092A1 publication Critical patent/WO2020233092A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Definitions

  • This application relates to a smart contract invocation method, device, computer equipment and storage medium.
  • a method, device, device, and storage medium for invoking a smart contract are provided.
  • a smart contract calling method is applied to a blockchain node in a blockchain node cluster, and the method includes:
  • the communication type configured corresponding to the smart contract identifier is determined
  • the dynamic link library file corresponding to the smart contract identifier is called through the dynamic file calling function; the dynamic link library file is generated by compiling the smart contract script corresponding to the smart contract identifier through a dynamic library compilation method Documents; and
  • the operation corresponding to the blockchain operation instruction is executed.
  • a smart contract invocation device includes:
  • the determining module is used to determine the communication type configured corresponding to the smart contract identifier when a blockchain operation instruction carrying the smart contract identifier is detected;
  • the determining module is also used to determine the corresponding dynamic file calling function when the communication type is inter-process communication;
  • the calling module is used to call the dynamic link library file corresponding to the smart contract identifier through the dynamic file calling function; the dynamic link library file is compiled through the dynamic library, for the smart contract corresponding to the smart contract identifier The files generated by the script compiling; and
  • the execution module is used to execute the operation corresponding to the block chain operation instruction according to the called dynamic link library file.
  • a computer device including a memory and one or more processors, the memory stores computer readable instructions, when the computer readable instructions are executed by the processor, the one or more processors execute The following steps:
  • the communication type configured corresponding to the smart contract identifier is determined
  • the dynamic link library file corresponding to the smart contract identifier is called through the dynamic file calling function; the dynamic link library file is generated by compiling the smart contract script corresponding to the smart contract identifier through a dynamic library compilation method Documents; and
  • the operation corresponding to the blockchain operation instruction is executed.
  • One or more non-volatile computer-readable storage media storing computer-readable instructions.
  • the one or more processors execute the following steps:
  • the communication type configured corresponding to the smart contract identifier is determined
  • the dynamic link library file corresponding to the smart contract identifier is called through the dynamic file calling function; the dynamic link library file is generated by compiling the smart contract script corresponding to the smart contract identifier through a dynamic library compilation method Documents; and
  • the operation corresponding to the blockchain operation instruction is executed.
  • Fig. 1 is an application scenario diagram of a smart contract invocation method according to one or more embodiments.
  • Fig. 2 is a schematic flowchart of a method for invoking a smart contract according to one or more embodiments.
  • Fig. 3 is a schematic flowchart of the steps of generating a dynamic link library file according to one or more embodiments.
  • Fig. 4 is a block diagram of a device for invoking a smart contract according to one or more embodiments.
  • Figure 5 is a block diagram of a smart contract invoking device in another embodiment.
  • Figure 6 is a block diagram of a computer device according to one or more embodiments.
  • the smart contract calling method provided in this application can be applied to the application environment as shown in Figure 1.
  • the terminal 110 communicates with the block chain node 120 through the network.
  • Each block chain node in the block chain node cluster communicates with each other through the block chain network connection.
  • the code configuration terminal 130 communicates with the blockchain node 120 through the network.
  • the smart contract platform 140 communicates with the blockchain node 120 through the blockchain network.
  • the blockchain node 121 receives the blockchain operation instruction sent by the terminal 110 and executes the above-mentioned smart contract invocation method.
  • the blockchain node 121 may also receive the smart contract file uploaded by the code configuration terminal 130, generate a corresponding signature verification request according to the smart contract file, and send the signature verification request to the smart contract platform 140 for signature verification. After the verification is passed, the configuration of the smart contract is realized according to the smart contract file.
  • the terminal 110 and the code configuration terminal 130 can be, but are not limited to, various personal computers, laptops, smart phones, tablets, and portable wearable devices.
  • the blockchain node 121 and smart contract platform can use independent servers or multiple servers.
  • the server cluster is composed to achieve.
  • a smart contract invoking method is provided. Taking the method applied to the blockchain nodes in the blockchain node cluster in FIG. 1 as an example, the method includes the following steps:
  • the above-mentioned blockchain operation instructions are instructions used to trigger the execution of data operations based on the blockchain network.
  • Data operations based on blockchain networks such as writing data to data blocks in blockchain nodes, or querying corresponding data from blockchain nodes, etc.
  • the smart contract identifier is used to uniquely identify the corresponding smart contract.
  • the smart contract identifier can specifically be letters, characters, numbers, Chinese characters, or strings.
  • Smart contracts are computer-readable instructions that can automatically perform corresponding operations according to preset rules.
  • Communication types include inter-process communication and intra-process communication. Inter-process communication needs to establish a communication channel between the two processes that communicate, and intra-process communication does not need to establish a communication channel.
  • the blockchain node when other computer equipment needs to communicate with the blockchain node, it can initiate a blockchain operation instruction to the blockchain node.
  • Data communication with blockchain nodes such as uploading data to the chain, that is, writing data to the data block in the blockchain node, or querying/obtaining data from the blockchain node, etc.
  • the smart contract identifier can be extracted from the blockchain operation instruction, and then the communication type configured corresponding to the smart contract identifier can be determined.
  • the blockchain node may pre-store the smart contract identifier and the association relationship of the corresponding communication type. In this way, the blockchain node can directly determine the communication type corresponding to the smart contract identifier.
  • the blockchain node receives the smart contract script uploaded by the code configuration terminal and the pre-configured communication method.
  • the blockchain node stores the smart contract script and extracts the smart contract identifier of the smart contract script and the configured communication method, and stores the smart contract identifier and the communication method in association.
  • the inter-process communication mentioned above is to spread or exchange information between different processes.
  • the blockchain node can search for the communication type stored in association with the smart contract identifier from the locally stored files.
  • the blockchain node can determine the dynamic file call function corresponding to the blockchain operation instruction.
  • a dynamic link library file also called a DDL (Dynamic Link Library) file
  • DDL Dynamic Link Library
  • the blockchain node may query the dynamic link library file corresponding to the smart contract identifier from the dynamic link library according to the determined dynamic file calling function, and then execute the queried dynamic link library file.
  • the above-mentioned dynamic link library file is a file generated by compiling the smart contract script corresponding to the smart contract identifier through the dynamic library compilation method.
  • the smart contract script may specifically be smart contract code.
  • the smart contract identifier is used to distinguish different smart contracts, and the smart contract script corresponding to the smart contract identifier is used to generate a corresponding dynamic link library file.
  • the role played by the dynamic link library file in each embodiment of the present application is equivalent to the role played by the smart contract, that is, the dynamic link library file compiled and generated according to the smart contract script is used to characterize the corresponding smart contract. It can be understood that the smart contract identifier is also used to distinguish different dynamic link library files.
  • a blockchain node When a blockchain node detects a blockchain operation instruction carrying a smart contract identifier, it can determine the corresponding dynamic link library text according to the smart contract identifier, and call the dynamic link library text corresponding to the smart contract identifier to realize the call and The smart contract identification corresponds to the function of the smart contract.
  • the blockchain node may compile the smart contract script corresponding to the smart contract identifier through a dynamic library compilation method in advance to generate a corresponding dynamic link library file.
  • the dynamic link library file corresponding to the smart contract identifier can be directly called through the dynamic file call function.
  • the blockchain node can also compile the smart contract script corresponding to the smart contract ID to generate the corresponding dynamic link library file through the dynamic library compilation method when it needs to call the smart contract, and then call the corresponding function through the dynamic file call function.
  • the dynamic link library file may be used to generate a corresponding dynamic link library file.
  • the blockchain node calls the dynamic link library file corresponding to the smart contract identifier through the dynamic file call function, thereby implementing the call of the smart contract.
  • This avoids the need to create different channels when invoking a smart contract whose communication type is an inter-process communication type, so as to implement smart contract invocation through communication between different channels.
  • the inter-process communication is converted to in-process communication to call the smart contract (that is, the dynamic link library file is called through the dynamic file call function The way to call the smart contract), thereby improving the calling efficiency of the smart contract, and then improving the efficiency of the corresponding data processing of the blockchain node.
  • the smart contract invocation method further includes a step of generating a dynamic link library file, and this step specifically includes the following steps:
  • the aforementioned script compilation instruction is used to trigger a script compilation action, which in this embodiment specifically refers to the action of deploying a smart contract, that is, instantiating a smart contract.
  • the blockchain node can obtain the script compilation instruction carrying the smart contract identifier.
  • the script compilation instruction can be triggered locally at a regular time, or it can be sent to the blockchain node by other computer equipment.
  • the block chain node receives the smart contract script uploaded by the code configuration terminal and the corresponding configured communication mode, the block chain node stores the smart contract script, and extracts the smart contract identifier of the smart contract script and the configured communication mode , Store the smart contract identifier and the communication method correspondingly.
  • the blockchain node when the blockchain node detects that the smart contract script is uploaded, it can directly obtain the smart contract identifier corresponding to the uploaded smart contract script, generate script compilation instructions according to the smart contract identifier, and then upload the script according to the script compilation instructions.
  • the smart contract script is compiled.
  • S304 Determine the communication type corresponding to the smart contract identifier according to the script compilation instruction.
  • the blockchain node can query the communication type corresponding to the smart contract identifier before compiling the smart contract script.
  • the above-mentioned dynamic library compilation information is configuration information required for compiling library files, which may specifically include storage location, file type, and interface information. Specifically, when the communication mode corresponding to the smart contract script is inter-process communication, the blockchain node can obtain the dynamic library compilation information and the smart contract script corresponding to the smart contract identifier.
  • the smart contract script is compiled in a dynamic library compilation method to generate a corresponding dynamic link library file.
  • the blockchain node can modify the smart contract script, and modify the compilation method of the smart contract script to the dynamic library compilation method.
  • the smart contract script is compiled using the dynamic library compilation method to generate the corresponding dynamic link library file.
  • the dynamic library compilation information includes dynamic library interface compilation information.
  • Step S308 that is, according to the dynamic library compilation information, the smart contract script is compiled by the dynamic library compilation method, and the step of generating the corresponding dynamic link library file specifically includes: adding the dynamic library interface compilation information to the smart contract script; reading; The dynamic library interface compiles information, and the smart contract script is compiled into a dynamic link library file matching the dynamic library according to the dynamic library interface compiling information using the dynamic library compilation method.
  • the blockchain node can add dynamic library interface compilation information to the smart contract script.
  • Read the dynamic library interface compilation information and use the dynamic library compilation method to compile the smart contract script into a dynamic link library file matching the dynamic library according to the dynamic library interface compilation information.
  • the dynamic link library file is loaded into the process. In this way, the information can be compiled through the configured interface, and the smart contract script can be quickly and accurately compiled into a dynamic link library file matching the dynamic library.
  • the uploaded smart contract script is compiled according to the dynamic library compilation information to obtain the dynamic link library file.
  • the dynamic link library file can be called directly according to the internal function to realize the action of the smart contract, avoiding the process of establishing communication with another process, and transforming the communication between processes For internal communication between processes, the efficiency of deploying smart contracts is improved.
  • the block chain node can load the queried dynamic link library file, and realize the operation corresponding to the block chain operation instruction by loading the dynamic link library file.
  • the blockchain node realizes the operation of adding accounting data by loading a dynamic link library file.
  • the communication type configured corresponding to the smart contract identifier is determined.
  • the communication type is inter-process communication
  • the corresponding dynamic file calling function is determined, and the dynamic link library file corresponding to the smart contract identifier is called through the dynamic file calling function to execute the operation corresponding to the blockchain operation instruction.
  • the dynamic link library file is a file generated by compiling the smart contract script corresponding to the smart contract identifier through the dynamic library compilation method.
  • the smart contract invoking method further includes the step of executing the operation corresponding to the blockchain operation instruction when the communication type is in-process communication.
  • This step specifically includes: when the communication type is in-process communication, obtaining and The smart contract compilation file corresponding to the smart contract ID; the smart contract compilation file is a file generated by directly compiling the smart contract script corresponding to the smart contract ID; the smart contract compilation file is used to execute the operation corresponding to the blockchain operation instruction.
  • the blockchain node can directly obtain the smart contract compilation file corresponding to the smart contract identifier.
  • the smart contract compilation file is a file generated by the blockchain node directly compiling according to the smart contract script corresponding to the smart contract identifier.
  • the blockchain node can compile the file according to the smart contract and execute the operation corresponding to the blockchain operation instruction.
  • the file when the pre-configured communication type corresponding to the smart contract identifier is in-process communication, the file can be compiled according to the smart contract to execute the operation corresponding to the blockchain operation instruction.
  • the smart contract compilation file is a file generated by directly compiling the smart contract script corresponding to the smart contract identifier. In this way, through intra-process communication, the efficiency of corresponding data processing by blockchain nodes can be improved.
  • the smart contract script is compiled using the dynamic library compilation method, and the step of generating the corresponding dynamic link library file specifically includes the following steps: determining the type of smart contract corresponding to the smart contract script; When the smart contract type is a source code contract, the compilation tool is called, and the smart contract script is compiled according to the dynamic library compilation information using the dynamic library compilation method to generate the corresponding dynamic link library file; load the dynamic link library file to the blockchain Each blockchain node in the node cluster.
  • a source code form contract refers to a contract compiled from source code, that is, the smart contract script is the source code. Specifically, after the blockchain node obtains the smart contract script, it can judge whether the smart contract corresponding to the smart contract script is a source code form contract, and if it is judged to be a source code form contract, it calls the compilation tool to compile the smart contract script , Generate the corresponding dynamic link library file, and load the corresponding dynamic link library file to each block chain node in the block chain node cluster.
  • compiling the smart contract script is to compile the source code of the smart contract into object code that can be directly executed by a computer or a virtual machine.
  • the compilation tool may specifically include a preprocessor, a compiler, a linker, etc. After inputting the source code into the preprocessor and the compiler, the object code is obtained, and the object code can be converted into an executable program or file through the linker.
  • the compilation tool is called, and the smart contract script is compiled according to the dynamic library compilation information using the dynamic library compilation method to generate the corresponding dynamic link library file, and the source code can be compiled into The dynamic link library file is loaded on the blockchain node.
  • the smart contract-based calling method further includes a signature verification step, which specifically includes: receiving a smart contract file sent by a code configuration terminal; the smart contract file includes a smart contract script and a digital signature corresponding to the code configuration terminal ; Generate the corresponding signature verification request according to the smart contract file; send a signature verification request to the smart contract platform; the signature verification request is used to instruct the smart contract platform to verify the digital signature in the smart contract file; when the smart contract platform feedback is received When the feedback information passed by the signature verification is executed, the script compiling instruction carrying the smart contract identifier is executed.
  • a signature verification step specifically includes: receiving a smart contract file sent by a code configuration terminal; the smart contract file includes a smart contract script and a digital signature corresponding to the code configuration terminal ; Generate the corresponding signature verification request according to the smart contract file; send a signature verification request to the smart contract platform; the signature verification request is used to instruct the smart contract platform to verify the digital signature in the smart contract file; when the smart contract platform feedback is received When the feedback information passed
  • the blockchain node may receive a smart contract file sent by the code configuration terminal, and the smart contract file includes a smart contract script and a digital signature corresponding to the code configuration terminal.
  • the blockchain node generates a corresponding signature verification request according to the smart contract file, and sends the signature verification request to the smart contract platform.
  • the smart contract platform verifies the digital signature in the smart contract file after receiving the signature verification request.
  • the blockchain node receives the feedback information from the smart contract platform indicating that the signature verification is passed, it deploys the smart contract on the local node of the blockchain node, that is, executes the script compilation instruction that carries the smart contract identifier.
  • the smart contract platform is a centralized or decentralized smart contract storage system that can audit, compile, and distribute smart contracts.
  • a typical smart contract platform can be a computer device that carries functions such as auditing, compiling, and issuing smart contracts.
  • the code configuration terminal uses a hash function to hash the smart contract script to obtain summary information. Then use the code to configure the private key of the terminal to encrypt the digest information and generate the corresponding digital signature.
  • the code configuration terminal can send the smart contract script and digital signature to the blockchain node. After the blockchain node receives the smart contract script and digital signature, it reports to the smart contract platform.
  • the smart contract platform decrypts and verifies the digital signature according to the public key corresponding to the code configuration terminal, and feeds back information to the blockchain node after the verification is passed.
  • executing the step of obtaining the script compilation instruction carrying the smart contract identifier specifically includes: when receiving the signature verification feedback from the smart contract platform When the feedback information is passed, the platform digital signature in the feedback information is extracted; the platform digital signature is verified; when the platform digital signature is verified, the script compilation instruction that carries the smart contract identifier is executed.
  • the platform digital signature is carried in the feedback information fed back by the smart contract platform indicating that the signature verification has passed.
  • the digital signature of the platform is generated after the smart contract platform uses the corresponding private key to encrypt the verification result.
  • the verification result is the result of verifying the digital signature corresponding to the code configuration terminal.
  • the smart contract platform can send the verification result and the platform digital signature to the blockchain node.
  • the blockchain node decrypts and verifies the platform digital signature through the public key corresponding to the smart contract platform. After the platform digital signature is verified, the target smart contract is deployed on the local node.
  • the local blockchain node can obtain the information fed back by the smart contract platform in the following ways.
  • the first method is to receive the information released by the smart contract platform to the blockchain network;
  • the second method is to receive the information released by the creation node of the blockchain network in the blockchain network;
  • the third method is from other areas in the blockchain network.
  • Block chain node obtains, other block chain nodes obtain corresponding information from smart contract platform or create node in advance.
  • the local blockchain node can obtain the information fed back by the smart contract platform in the following two ways.
  • Method one is to receive information released by the smart contract platform to the blockchain network.
  • the second method is to send a signature verification request to the smart contract platform and receive feedback information issued by the smart contract platform.
  • the smart contract file sent by the code configuration terminal is verified through the smart contract platform, and the smart contract script is compiled after the verification is passed to realize the deployment of the smart contract, which can ensure the legality and security of the locally deployed smart contract .
  • the smart contract when the user installs the smart contract, can be deployed in the following two ways.
  • the first type upload the smart contract source code to the blockchain node, compile the smart contract source code, and obtain a binary program or file.
  • the second type select the compiled executable program or the library file according to the user's selection instruction, and load the selected executable program or library file directly into the blockchain node to complete the installation of the smart contract. Deploying the smart contract in the second method mentioned above can protect the source code of the smart contract by directly uploading the executable program or library file of the smart contract.
  • a smart contract invoking device 400 including: a determining module 401, a calling module 402, and an executing module 403, wherein:
  • the determining module 401 is configured to determine the communication type configured corresponding to the smart contract identifier when the blockchain operation instruction carrying the smart contract identifier is detected.
  • the determining module 401 is also used to determine the corresponding dynamic file calling function when the communication type is inter-process communication.
  • the calling module 402 is used to call the dynamic link library file corresponding to the smart contract identification through the dynamic file calling function; the dynamic link library file is the file generated by compiling the smart contract script corresponding to the smart contract identification through the dynamic library compilation method .
  • the execution module 403 is used to execute the operation corresponding to the blockchain operation instruction according to the called dynamic link library file.
  • the smart contract invoking device 400 further includes an obtaining module 404.
  • the obtaining module 404 is also used to obtain the smart contract compilation file corresponding to the smart contract identifier when the communication type is in-process communication; the smart contract compilation file is A file generated by directly compiling the smart contract script corresponding to the smart contract identifier.
  • the execution module 403 is also used to compile files according to the smart contract and execute operations corresponding to the blockchain operation instructions.
  • the smart contract invoking device 400 further includes a compiling module 405, wherein:
  • the obtaining module 404 is also used to obtain a script compilation instruction carrying a smart contract identifier.
  • the determining module 401 is further configured to determine the communication type corresponding to the smart contract identifier according to the script compilation instruction.
  • the obtaining module 404 is also used to obtain the dynamic library compilation information and the smart contract script corresponding to the smart contract identifier when the determined communication type is inter-process communication.
  • the compiling module 405 is used to compile the smart contract script in a dynamic library compilation method according to the dynamic library compilation information, and generate a corresponding dynamic link library file.
  • the dynamic library compilation information includes dynamic library interface compilation information.
  • the compilation module 405 is also used to add the dynamic library interface compilation information to the smart contract script; read the dynamic library interface compilation information, and use the dynamic library compilation method to compile the smart contract script into a dynamic library matching the dynamic library interface compilation information. Link library files.
  • the compilation module 405 is also used to determine the smart contract type corresponding to the smart contract script; when the smart contract type is a source code form contract, the compilation tool is invoked, and the dynamic library compilation method is used to compile the data according to the dynamic library compilation information.
  • the smart contract script is compiled to generate the corresponding dynamic link library file; the dynamic link library file is loaded to each block chain node in the block chain node cluster.
  • the smart contract invoking device 400 further includes a receiving module 406, a generating module 407, and a sending module 408, where:
  • the receiving module 406 is used to receive the smart contract file sent by the code configuration terminal; the smart contract file includes a smart contract script and a digital signature corresponding to the code configuration terminal.
  • the generation module 407 is used to generate a corresponding signature verification request according to the smart contract file.
  • the sending module 408 is used to send a signature verification request to the smart contract platform; the signature verification request is used to instruct the smart contract platform to verify the digital signature in the smart contract file.
  • the execution module 403 is also used to execute the script compiling instruction that carries the smart contract identifier when receiving the feedback information indicating that the signature verification passed from the smart contract platform.
  • the execution module 403 is also used for extracting the platform digital signature in the feedback information when receiving the feedback information indicating that the signature verification passed by the smart contract platform; verifying the platform digital signature; when the platform digital signature is passed After verification, execute to obtain the script compilation instruction carrying the smart contract identifier.
  • the above smart contract invoking device determines the communication type configured corresponding to the smart contract identifier when it detects a block chain operation instruction carrying the smart contract identifier.
  • the communication type is inter-process communication
  • the corresponding dynamic file calling function is determined, and the dynamic link library file corresponding to the smart contract identifier is called through the dynamic file calling function to execute the operation corresponding to the blockchain operation instruction.
  • the dynamic link library file is a file generated by compiling the smart contract script corresponding to the smart contract identifier through the dynamic library compilation method.
  • Each module in the above-mentioned smart contract invoking device can be implemented in whole or in part by software, hardware and a combination thereof.
  • the foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
  • a computer device is provided.
  • the computer device may be a blockchain node, and its internal structure diagram may be as shown in FIG. 6.
  • the computer equipment includes a processor, a memory, and a network interface connected through a system bus.
  • the processor of the computer device is used to provide calculation 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, computer readable instructions, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer-readable instruction is executed by the processor to realize a smart contract calling method.
  • FIG. 6 is only a block diagram of 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 Including more or fewer parts than shown in the figure, or combining some parts, or having a different arrangement of parts.
  • a computer device including a memory and one or more processors.
  • the memory stores computer-readable instructions.
  • the one or more processors execute The steps of the above smart contract calling method.
  • the steps of the smart contract invoking method may be the steps in the smart contract invoking method in each of the above embodiments.
  • one or more non-volatile computer-readable storage media storing computer-readable instructions are provided.
  • the computer-readable instructions are executed by one or more processors, the one or more processors Perform the steps of the smart contract call method described above.
  • the steps of the smart contract invoking method may be the steps in the smart contract invoking method in each of the above embodiments.
  • Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
  • SRAM static RAM
  • DRAM dynamic RAM
  • SDRAM synchronous DRAM
  • DDRSDRAM double data rate SDRAM
  • ESDRAM enhanced SDRAM
  • SLDRAM synchronous chain Channel
  • memory bus Radbus direct RAM
  • RDRAM direct memory bus dynamic RAM
  • RDRAM memory bus dynamic RAM

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

一种智能合约调用方法,包括:当检测到携带有智能合约标识的区块链操作指令时,则确定与所述智能合约标识相应配置的通信类型;当所述通信类型为进程间通信时,确定相应的动态文件调用函数;通过所述动态文件调用函数调用与所述智能合约标识对应的动态链接库文件;所述动态链接库文件是通过动态库编译方式,对与所述智能合约标识相应的智能合约脚本进行编译所生成的文件;及根据调用的所述动态链接库文件,执行与所述区块链操作指令对应的操作。

Description

智能合约调用方法、装置、设备和存储介质
相关申请的交叉引用
本申请要求于2019年05月21日提交中国专利局,申请号为201910424301.X,申请名称为“智能合约调用方法、装置、设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及一种智能合约调用方法、装置、计算机设备和存储介质。
背景技术
随着数据处理技术的发展,出现了区块链技术,通过区块链技术对数据进行处理,可以提高数据的安全性。通常在创建区块链网络后,需要通过智能合约为区块链网络中的各区块链节点添加数据处理功能。在实际应用中,可以通过部署各种智能合约为区块链添节点添加相应的数据处理能力。
然而,区块链节点通过部署的智能合约实现相应操作时,常常需要在进程间建立通信通道,以调用智能合约。发明人意识到,在进程间建立通信通道,延长了与智能合约进行通讯所耗费的时间,从而降低了区块链节点进行相应数据处理的效率。
发明内容
根据本申请公开的各种实施例,提供一种智能合约调用方法、装置、设备和存储介质。
一种智能合约调用方法,应用于区块链节点集群中的区块链节点,所述方法包括:
当检测到携带有智能合约标识的区块链操作指令时,则确定与所述智能合约标识相应配置的通信类型;
当所述通信类型为进程间通信时,确定相应的动态文件调用函数;
通过所述动态文件调用函数调用与所述智能合约标识对应的动态链接库文件;所述动态链接库文件是通过动态库编译方式,对与所述智能合约标识相应的智能合约脚本进行编译所生成的文件;及
根据调用的所述动态链接库文件,执行与所述区块链操作指令对应的操作。
一种智能合约调用装置,所述装置包括:
确定模块,用于当检测到携带有智能合约标识的区块链操作指令时,则确定与所述智能合约标识相应配置的通信类型;
所述确定模块还用于当所述通信类型为进程间通信时,确定相应的动态文件调用函数;
调用模块,用于通过所述动态文件调用函数调用与所述智能合约标识对应的动态链接库文件;所述动态链接库文件是通过动态库编译方式,对与所述智能合约标识相应的智能合约脚本进行编译所生成的文件;及
执行模块,用于根据调用的所述动态链接库文件,执行与所述区块链操作指令对应的操作。
一种计算机设备,包括存储器和一个或多个处理器,所述存储器中储存有计算机可读指令,所述计算机可读指令被所述处理器执行时,使得所述一个或多个处理器执行以下步骤:
当检测到携带有智能合约标识的区块链操作指令时,则确定与所述智能合约标识相应配置的通信类型;
当所述通信类型为进程间通信时,确定相应的动态文件调用函数;
通过所述动态文件调用函数调用与所述智能合约标识对应的动态链接库文件;所述动态链接库文件是通过动态库编译方式,对与所述智能合约标识相应的智能合约脚本进行编译所生成的文件;及
根据调用的所述动态链接库文件,执行与所述区块链操作指令对应的操作。
一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行以下步骤:
当检测到携带有智能合约标识的区块链操作指令时,则确定与所述智能合约标识相应配置的通信类型;
当所述通信类型为进程间通信时,确定相应的动态文件调用函数;
通过所述动态文件调用函数调用与所述智能合约标识对应的动态链接库文件;所述动态链接库文件是通过动态库编译方式,对与所述智能合约标识相应的智能合约脚本进行编译所生成的文件;及
根据调用的所述动态链接库文件,执行与所述区块链操作指令对应的操作。
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请 的其它特征和优点将从说明书、附图以及权利要求书变得明显。
附图说明
图1为根据一个或多个实施例中智能合约调用方法的应用场景图。
图2为根据一个或多个实施例中智能合约调用方法的流程示意图。
图3为根据一个或多个实施例中动态链接库文件的生成步骤的流程示意图。
图4为根据一个或多个实施例中智能合约调用装置的框图。
图5为另一个实施例中智能合约调用装置的框图。
图6为根据一个或多个实施例中计算机设备的框图。
具体实施方式
为了使本申请的技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
本申请提供的智能合约调用方法,可以应用于如图1所示的应用环境中。终端110通过网络与区块链节点区块链节点120进行通信。区块链节点集群中的各区块链节点通过区块链网络连接互相通信。代码配置终端130通过网络与区块链节点120进行通信。智能合约平台140通过区块链网络与区块链节点120进行通信。
具体地,区块链节点121接收终端110发送的区块链操作指令并执行上述智能合约调用方法。区块链节点121还可接收代码配置终端130上传的智能合约文件,并根据智能合约文件生成相应的签名验证请求,向智能合约平台140发送签名验证请求以进行签名验证。当验证通过后根据该智能合约文件实现智能合约的配置。
终端110及代码配置终端130可以但不限于是各种个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备,区块链节点121及智能合约平台可以用独立的服务器或者是多个服务器组成的服务器集群来实现。
在一些实施例中,如图2所示,提供了一种智能合约调用方法,以该方法应用于图1中的区块链节点集群中的区块链节点为例进行说明,包括以下步骤:
S202,当检测到携带有智能合约标识的区块链操作指令时,则确定与智能合约标识相应配置的通信类型。
上述的区块链操作指令是用于触发执行基于区块链网络的数据操作的指令。基于区块链网络的数据操作,比如将数据写入区块链节点中的数据区块, 或从区块链节点中查询相应数据等的操作。智能合约标识用于唯一标识相应的智能合约,智能合约标识具体可以是字母、字符、数字、汉字或字符串等。智能合约是可以依据预先设置的规则自动执行相应操作的计算机可读指令。通信类型包括进程间通信和进程内通信。进程间通信需要建立通信的两个进程之间的通信通道,进程内通信无需建立通信通道。
具体地,当其他计算机设备需与区块链节点进行数据通讯时,可向区块链节点发起区块链操作指令。与区块链节点进行数据通讯,比如将数据进行上链操作,也就是将数据写入区块链节点中的数据区块,或者从区块链节点中查询/获取数据等。当区块链节点检测到区块链操作指令时,可从区块链操作指令中提取出智能合约标识,进而确定与智能合约标识相应配置的通信类型。在一些实施例中,区块链节点可预先存储智能合约标识、及相应通信类型的关联关系,这样,区块链节点就可直接确定与智能合约标识相应配置的通信类型。
在一些实施例中,区块链节点接收代码配置终端上传的智能合约脚本和预配置的通信方式。区块链节点将智能合约脚本进行存储并提取智能合约脚本的智能合约标识和配置的通信方式,将智能合约标识与通信方式关联存储。
S204,当通信类型为进程间通信时,确定相应的动态文件调用函数。
上述所提及的进程间通信是在不同进程之间传播或交换信息。具体地,区块链节点可从本地存储的文件中查找与智能合约标识关联存储的通信类型。当确定的通过类型为进程间通信时,区块链节点可确定与该区块链操作指令对应的动态文件调用函数。
S206,通过动态文件调用函数调用与智能合约标识对应的动态链接库文件;动态链接库文件是通过动态库编译方式,对与智能合约标识相应的智能合约脚本进行编译所生成的文件。
动态链接库文件,也称DDL(Dynamic Link Library)文件,是一种软件文件类型,当计算机设备执行某一个程序时,可调用相应的DLL文件。具体地,区块链节点可根据确定的动态文件调用函数从动态链接库中查询与该智能合约标识对应的动态链接库文件,进而执行查询到的动态链接库文件。上述所提及的动态链接库文件是通过动态库编译方式,对与智能合约标识相应的智能合约脚本进行编译所生成的文件。智能合约脚本具体可以是智能合约代码。
在一些实施例中,智能合约标识用于区分不同的智能合约,与智能合约标识对应的智能合约脚本用于生成相应的动态链接库文件。动态链接库文件在本申请各实施例中所起到的作用等同于智能合约所起的作用,也就是根据智能合约脚本编译生成的动态链接库文件用于表征相应的智能合约。可以理 解,智能合约标识还用于区分不同的动态链接库文件。当区块链节点检测到携带有智能合约标识的区块链操作指令时,可根据智能合约标识确定相应的动态链接库文本,通过调用与智能合约标识对应的动态链接库文本,来实现调用与智能合约标识对应智能合约的功能。
在一些实施例中,区块链节点可预先通过动态库编译方式,对与智能合约标识相应的智能合约脚本进行编译生成相应的动态链接库文件。在检测到携带有智能合约标识的区块链操作指令时,就可直接通过动态文件调用函数调用与智能合约标识相应动态链接库文件。或者,区块链节点还可在需要调用智能合约时,实时通过动态库编译方式,对与智能合约标识相应的智能合约脚本进行编译生成相应的动态链接库文件,再通过动态文件调用函数调用相应的动态链接库文件。
在一些实施例中,区块链节点通过动态文件调用函数调用与智能合约标识对应的动态链接库文件,从而实现智能合约的调用。避免了当调用通信类型为进程间通信类型的智能合约时必须创建不同的信道,以通过不同信道间的通信来实现智能合约的调用。通过本申请中的各实施例,无需创建多个不同的信道,在调用智能合约时,将进程间通信转换成进程内通信即可调用智能合约(也就是通过动态文件调用函数调用动态链接库文件的方式来调用智能合约),从而提高了智能合约的调用效率,进而提高了区块链节点进行相应数据处理的效率。在一些实施例中,该智能合约调用方法还包括动态链接库文件的生成步骤,该步骤具体包括以下步骤:
S302,获取携带有智能合约标识的脚本编译指令。
上述的脚本编译指令用于触发脚本编译动作,该脚本编译动作在本实施例中具体指部署智能合约的动作,也就是实例化智能合约。具体地,区块链节点可获取携带有智能合约标识的脚本编译指令。该脚本编译指令可以是本地定时触发的,也可以是其他计算机设备发送至区块链节点。
在一些实施例中,区块链节点接收代码配置终端上传的智能合约脚本和相应配置的通信方式,区块链节点将智能合约脚本进行存储,提取智能合约脚本的智能合约标识和配置的通信方式,将智能合约标识与通讯方式对应存储。
在一些实施例中,区块链节点在检测到智能合约脚本上传时,可直接获取上传的智能合约脚本对应的智能合约标识,根据该智能合约标识生成脚本编译指令,进而根据脚本编译指令对上传的智能合约脚本进行编译。
S304,根据脚本编译指令确定与智能合约标识对应的通信类型。
具体地,区块链节点在对智能合约脚本进行编译前,可查询与智能合约标识对应的通信类型。
S306,当确定的通信类型为进程间通信时,获取动态库编译信息和与智能合约标识对应的智能合约脚本。
上述的动态库编译信息是编译库文件所需的配置信息,具体可包括存储位置、文件类型、及接口信息等。具体地,当智能合约脚本对应的通信方式为进程间通信时,区块链节点可获取动态库编译信息和与智能合约标识对应的智能合约脚本。
S308,按照动态库编译信息,采用动态库编译方式对智能合约脚本进行编译,生成相应的动态链接库文件。
具体地,区块链节点可对智能合约脚本进行修改,将智能合约脚本的编译方式修改为动态库编译方式。按照动态库编译信息,采用动态库编译方式对智能合约脚本进行编译,生成相应的动态链接库文件。
在一些实施例中,动态库编译信息包括动态库接口编译信息。步骤S308,也就是按照动态库编译信息,采用动态库编译方式对智能合约脚本进行编译,生成相应的动态链接库文件的步骤具体包括:将动态库接口编译信息添加至智能合约脚本中;读取动态库接口编译信息,采用动态库编译方式根据动态库接口编译信息将智能合约脚本编译为与动态库匹配的动态链接库文件。
具体地,区块链节点可将动态库接口编译信息添加至智能合约脚本中。读取动态库接口编译信息,采用动态库编译方式根据动态库接口编译信息将智能合约脚本编译为与动态库匹配的动态链接库文件。在生成动态链接库文件后,将动态链接库文件加载到进程中。这样,可通过配置的接口编译信息,快捷准确地将智能合约脚本编译为与动态库匹配的动态链接库文件。
上述实施例中,在实例化智能合约的时候,检测到智能合约对应的通信方式为进程间通信时,根据动态库编译信息对上传的智能合约脚本进行编译,得到动态链接库文件。这样,在部署智能合约时,无需与另外的进程建立通信连接,可直接根据内部函数调用动态链接库文件,以实现智能合约的动作,避免了与另外进程建立通信的过程,将进程间通信转化为进程内部通信,提高了部署智能合约的效率。
S208,根据调用的动态链接库文件,执行与区块链操作指令对应的操作。
具体地,区块链节点可加载查询到的动态链接库文件,通过加载动态链接库文件,实现与区块链操作指令相应的操作。比如,区块链节点通过加载动态链接库文件实现添加记账数据的操作。
上述智能合约调用方法,当检测到携带有智能合约标识的区块链操作指令时,确定与该智能合约标识相应配置的通信类型。当通信类型为进程间通信时,确定相应的动态文件调用函数,通过该动态文件调用函数调用与智能合约标识对应的动态链接库文件,以执行与区块链操作指令对应的操作。动 态链接库文件是通过动态库编译方式,对与智能合约标识相应的智能合约脚本进行编译所生成的文件。这样,当需调用通信类型为进程间通信类型的智能合约执行相应的数据操作时,无需与另外的进程建立通信连接,可直接根据内部的动态文件调用函数调用动态链接库文件,通过动态链接库文件来实现区块链操作指令对应的动作。可以避免与另外进程建立通信的过程,将进程间通信转化为进程内部通信,大大提高了区块链节点进行相应数据处理的效率。
在一些实施例中,该智能合约调用方法还包括当通信类型为进程内通信时,执行区块链操作指令对应的操作的步骤,该步骤具体包括:当通信类型为进程内通信时,获取与智能合约标识对应的智能合约编译文件;智能合约编译文件是对与智能合约标识相应的智能合约脚本进行直接编译所生成的文件;根据智能合约编译文件,执行与区块链操作指令对应的操作。
具体地,当与智能合约标识对应的预配置的通信类型为进程内通信时,区块链节点则可直接获取与智能合约标识对应的智能合约编译文件。该智能合约编译文件为区块链节点根据与智能合约标识相应的智能合约脚本进行直接编译而生成的文件。区块链节点可根据该智能合约编译文件,执行与区块链操作指令对应的操作。
上述实施例中,当与智能合约标识对应的预配置的通信类型为进程内通信时,则可根据智能合约编译文件,执行与区块链操作指令对应的操作。该智能合约编译文件是对与智能合约标识相应的智能合约脚本进行直接编译所生成的文件。这样,通过进程内部通信,可以提高区块链节点进行相应数据处理的效率。
在一些实施例中,按照动态库编译信息,采用动态库编译方式对智能合约脚本进行编译,生成相应的动态链接库文件的步骤具体包括以下步骤:确定智能合约脚本所对应的智能合约类型;当智能合约类型为源代码形式合约时,调用编译工具,按照动态库编译信息,采用动态库编译方式对智能合约脚本进行编译,生成相应的动态链接库文件;将动态链接库文件加载至区块链节点集群中的各区块链节点。
源代码形式合约是指根据源码编译而成的合约,也就是该智能合约脚本为源代码。具体地,区块链节点在获取到智能合约脚本后,可判断智能合约脚本所对应的智能合约是否为源代码形式合约,若判定为源代码形式合约,则调用编译工具对智能合约脚本进行编译,生成相应的动态链接库文件,将相应的动态链接库文件加载到区块链节点集群中的各区块链节点上。
在一些实施例中,对智能合约脚本进行编译是将智能合约的源代码编译成能直接被计算机或虚拟机执行的目标代码。编译工具具体可包括预处理器、 编译器和链接器等。将源代码输入至预处理器和编译器后,得到目标代码,通过链接器可将目标代码转化成可执行程序或文件。
上述实施例中,当智能合约脚本为源代码时,调用编译工具,按照动态库编译信息,采用动态库编译方式对智能合约脚本进行编译,生成相应的动态链接库文件,可以将源代码编译成动态链接库文件并加载到区块链节点上。
在一些实施例中,该基于智能合约调用方法还包括签名验证的步骤,该步骤具体包括:接收代码配置终端发送的智能合约文件;智能合约文件包括智能合约脚本和与代码配置终端相应的数字签名;根据智能合约文件生成相应的签名验证请求;向智能合约平台发送签名验证请求;签名验证请求用于指示智能合约平台对智能合约文件中的数字签名进行验证;当接收到智能合约平台反馈的表示签名验证通过的反馈信息时,执行获取携带有智能合约标识的脚本编译指令。
具体地,区块链节点可接收代码配置终端发送的智能合约文件,该智能合约文件包括智能合约脚本和与代码配置终端相应的数字签名。区块链节点根据智能合约文件生成相应的签名验证请求,并向智能合约平台发送签名验证请求。智能合约平台收到签名验证请求后对智能合约文件中的数字签名进行验证。当区块链节点接收到智能合约平台反馈的表示签名验证通过的反馈信息时,则在区块链节点本地节点部署智能合约,也就是执行获取携带有智能合约标识的脚本编译指令。
智能合约平台是一个中心化或去中心化的智能合约存储系统,可进行智能合约的审计、编译及下发等。典型的智能合约平台可以是一个承载智能合约审计、编译及下发等功能的计算机设备。
在一些实施例中,代码配置终端通过哈希函数对智能合约脚本进行哈希运算,得到摘要信息。再采用代码配置终端的私钥对摘要信息进行加密,生成相应的数字签名。代码配置终端可将智能合约脚本和数字签名一起发送至区块链节点。区块链节点收到智能合约脚本和数字签名后,则上报至智能合约平台。智能合约平台依据代码配置终端对应的公钥对数字签名进行解密验证,验证通过后向区块链节点反馈信息。
在一些实施例中,当接收到智能合约平台反馈的表示签名验证通过的反馈信息时,执行获取携带有智能合约标识的脚本编译指令的步骤具体包括:当接收到智能合约平台反馈的表示签名验证通过的反馈信息时,提取反馈信息中的平台数字签名;对平台数字签名进行验证;当平台数字签名通过验证后,执行获取携带有智能合约标识的脚本编译指令。
具体地,智能合约平台反馈的表示签名验证通过的反馈信息中携带平台数字签名。该平台数字签名是智能合约平台采用相应的私钥对验证结果进行 加密后所生成的。验证结果是对代码配置终端对应的数字签名进行验证的结果。智能合约平台可将验证结果和平台数字签名一起发送至区块链节点。
区块链节点通过与智能合约平台相应的公钥对平台数字签名进行解密验证,当平台数字签名通过验证后,在本地节点部署目标智能合约。
在一个实时例中,若本地区块链节点不是区块链网络的创建节点,则本地区块链节点可通过如下几种方式获取智能合约平台反馈的信息。方式一,接收智能合约平台向区块链网络发布的信息;方式二,接收区块链网络的创建节点在区块链网络中传递发布的信息;方式三,从区块链网络中的其他区块链节点获取,其他区块链节点预先从智能合约平台或创建节点获取相应信息。
在一些实施例中,若本地区块链节点是区块链网络的创建节点,则本地区块链节点可以通过以下两种方式获取智能合约平台反馈的信息。方式一,接收智能合约平台向区块链网络发布的信息。方式二,向智能合约平台发送签名验证请求,接收智能合约平台下发的反馈信息。
上述实施例中,通过智能合约平台对代码配置终端发送的智能合约文件进行验证,当验证通过后再编译智能合约脚本,实现智能合约的部署,可保障本地部署的智能合约的合法性和安全性。
在一些实施例中,用户在安装智能合约的时候,可通过以下两种方式部署智能合约。第一种:向区块链节点上传智能合约源码,对智能合约源码进行编译,得到二进制程序或文件。第二种:根据用户的选择指令选取已经编译好的可执行程序或这库文件,将选择的可执行程序或者库文件直接加载到区块链节点中,以完成安装智能合约。采用上述第二种方式部署智能合约,通过直接上传智能合约的可执行程序或者库文件,可以保护源码智能合约的源码。
应该理解的是,虽然图2-3的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2-3中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。
在一些实施例中,如图4所示,提供了一种智能合约调用装置400,包 括:确定模块401、调用模块402和执行模块403,其中:
确定模块401,用于当检测到携带有智能合约标识的区块链操作指令时,则确定与智能合约标识相应配置的通信类型。
确定模块401还用于当通信类型为进程间通信时,确定相应的动态文件调用函数。
调用模块402,用于通过动态文件调用函数调用与智能合约标识对应的动态链接库文件;动态链接库文件是通过动态库编译方式,对与智能合约标识相应的智能合约脚本进行编译所生成的文件。
执行模块403,用于根据调用的动态链接库文件,执行与区块链操作指令对应的操作。
在一些实施例中,该智能合约调用装置400还包括获取模块404,获取模块404还用于当通信类型为进程内通信时,获取与智能合约标识对应的智能合约编译文件;智能合约编译文件是对与智能合约标识相应的智能合约脚本进行直接编译所生成的文件。执行模块403还用于根据智能合约编译文件,执行与区块链操作指令对应的操作。
在一些实施例中,该智能合约调用装置400还包括编译模块405,其中:
获取模块404还用于获取携带有智能合约标识的脚本编译指令。
确定模块401还用于根据脚本编译指令确定与智能合约标识对应的通信类型。
获取模块404还用于当确定的通信类型为进程间通信时,获取动态库编译信息和与智能合约标识对应的智能合约脚本。
编译模块405,用于按照动态库编译信息,采用动态库编译方式对智能合约脚本进行编译,生成相应的动态链接库文件。
在一些实施例中,动态库编译信息包括动态库接口编译信息。编译模块405还用于将动态库接口编译信息添加至智能合约脚本中;读取动态库接口编译信息,采用动态库编译方式根据动态库接口编译信息将智能合约脚本编译为与动态库匹配的动态链接库文件。
在一些实施例中,编译模块405还用于确定智能合约脚本所对应的智能合约类型;当智能合约类型为源代码形式合约时,调用编译工具,按照动态库编译信息,采用动态库编译方式对智能合约脚本进行编译,生成相应的动态链接库文件;将动态链接库文件加载至区块链节点集群中的各区块链节点。
参考图5,在一些实施例中,该智能合约调用装置400还包括接收模块406、生成模块407和发送模块408,其中:
接收模块406,用于接收代码配置终端发送的智能合约文件;智能合约文件包括智能合约脚本和与代码配置终端相应的数字签名。
生成模块407,用于根据智能合约文件生成相应的签名验证请求。
发送模块408,用于向智能合约平台发送签名验证请求;签名验证请求用于指示智能合约平台对智能合约文件中的数字签名进行验证。
执行模块403还用于当接收到智能合约平台反馈的表示签名验证通过的反馈信息时,执行获取携带有智能合约标识的脚本编译指令。
在一些实施例中,执行模块403还用于当接收到智能合约平台反馈的表示签名验证通过的反馈信息时,提取反馈信息中的平台数字签名;对平台数字签名进行验证;当平台数字签名通过验证后,执行获取携带有智能合约标识的脚本编译指令。
上述智能合约调用装置,当检测到携带有智能合约标识的区块链操作指令时,确定与该智能合约标识相应配置的通信类型。当通信类型为进程间通信时,确定相应的动态文件调用函数,通过该动态文件调用函数调用与智能合约标识对应的动态链接库文件,以执行与区块链操作指令对应的操作。动态链接库文件是通过动态库编译方式,对与智能合约标识相应的智能合约脚本进行编译所生成的文件。这样,当需调用通信类型为进程间通信类型的智能合约执行相应的数据操作时,无需与另外的进程建立通信连接,可直接根据内部的动态文件调用函数调用动态链接库文件,通过动态链接库文件来实现区块链操作指令对应的动作。可以避免与另外进程建立通信的过程,将进程间通信转化为进程内部通信,大大提高了区块链节点进行相应数据处理的效率。
关于智能合约调用装置的具体限定可以参见上文中对于智能合约调用方法的限定,在此不再赘述。上述智能合约调用装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
在一些实施例中,提供了一种计算机设备,该计算机设备可以是区块链节点,其内部结构图可以如图6所示。该计算机设备包括通过系统总线连接的处理器、存储器和网络接口。该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现一种智能合约调用方法。
本领域技术人员可以理解,图6中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的 限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
在一些实施例中,提供了一种计算机设备,包括存储器和一个或多个处理器,存储器中储存有计算机可读指令,计算机可读指令被处理器执行时,使得一个或多个处理器执行上述智能合约调用方法的步骤。此处智能合约调用方法的步骤可以是上述各个实施例的智能合约调用方法中的步骤。
在一些实施例中,提供了一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行上述智能合约调用方法的步骤。此处智能合约调用方法的步骤可以是上述各个实施例的智能合约调用方法中的步骤。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。

Claims (20)

  1. 一种智能合约调用方法,应用于区块链节点集群中的区块链节点,包括:
    当检测到携带有智能合约标识的区块链操作指令时,则确定与所述智能合约标识相应配置的通信类型;
    当所述通信类型为进程间通信时,确定相应的动态文件调用函数;
    通过所述动态文件调用函数,调用与所述智能合约标识对应的动态链接库文件;所述动态链接库文件是通过动态库编译方式,对与所述智能合约标识相应的智能合约脚本进行编译所生成的文件;及
    根据调用的所述动态链接库文件,执行与所述区块链操作指令对应的操作。
  2. 根据权利要求1所述的方法,其特征在于,还包括:
    当所述通信类型为进程内通信时,获取与所述智能合约标识对应的智能合约编译文件;所述智能合约编译文件是对与所述智能合约标识相应的智能合约脚本进行直接编译所生成的文件;及
    根据所述智能合约编译文件,执行与所述区块链操作指令对应的操作。
  3. 根据权利要求1所述的方法,其特征在于,还包括:
    获取携带有智能合约标识的脚本编译指令;
    根据所述脚本编译指令确定与所述智能合约标识对应的通信类型;
    当确定的通信类型为进程间通信时,获取动态库编译信息和与所述智能合约标识对应的智能合约脚本;及
    按照所述动态库编译信息,采用动态库编译方式对所述智能合约脚本进行编译,生成相应的动态链接库文件。
  4. 根据权利要求3所述的方法,其特征在于,所述动态库编译信息包括动态库接口编译信息;所述按照所述动态库编译信息,采用动态库编译方式对所述智能合约脚本进行编译,生成相应的动态链接库文件,包括:
    将所述动态库接口编译信息添加至所述智能合约脚本中;及
    读取所述动态库接口编译信息,采用动态库编译方式根据所述动态库接口编译信息将所述智能合约脚本编译为与动态库匹配的动态链接库文件。
  5. 根据权利要求3所述的方法,其特征在于,所述按照所述动态库编译信息,采用动态库编译方式对所述智能合约脚本进行编译,生成相应的动态链接库文件,包括:
    确定所述智能合约脚本所对应的智能合约类型;
    当所述智能合约类型为源代码形式合约时,调用编译工具,按照所述动态库编译信息,采用动态库编译方式对所述智能合约脚本进行编译,生成相 应的动态链接库文件;及
    将所述动态链接库文件加载至所述区块链节点集群中的各区块链节点。
  6. 根据权利要求3至5任一项所述的方法,其特征在于,所述方法还包括:
    接收代码配置终端发送的智能合约文件;所述智能合约文件包括智能合约脚本和与所述代码配置终端相应的数字签名;
    根据所述智能合约文件生成相应的签名验证请求;
    向智能合约平台发送所述签名验证请求;所述签名验证请求用于指示所述智能合约平台对所述智能合约文件中的数字签名进行验证;及
    当接收到所述智能合约平台反馈的表示签名验证通过的反馈信息时,执行所述获取携带有智能合约标识的脚本编译指令。
  7. 根据权利要求6所述的方法,其特征在于,所述当接收到所述智能合约平台反馈的表示签名验证通过的反馈信息时,执行所述获取携带有智能合约标识的脚本编译指令,包括:
    当接收到所述智能合约平台反馈的表示签名验证通过的反馈信息时,提取所述反馈信息中的平台数字签名;
    对所述平台数字签名进行验证;及
    当所述平台数字签名通过验证后,执行所述获取携带有智能合约标识的脚本编译指令。
  8. 一种智能合约调用装置,包括:
    确定模块,用于当检测到携带有智能合约标识的区块链操作指令时,则确定与所述智能合约标识相应配置的通信类型;
    所述确定模块还用于当所述通信类型为进程间通信时,确定相应的动态文件调用函数;
    调用模块,用于通过所述动态文件调用函数调用与所述智能合约标识对应的动态链接库文件;所述动态链接库文件是通过动态库编译方式,对与所述智能合约标识相应的智能合约脚本进行编译所生成的文件;及
    执行模块,用于根据调用的所述动态链接库文件,执行与所述区块链操作指令对应的操作。
  9. 根据权利要求8所述的装置,其特征在于,还包括:
    获取模块,用于当所述通信类型为进程内通信时,获取与所述智能合约标识对应的智能合约编译文件;所述智能合约编译文件是对与所述智能合约标识相应的智能合约脚本进行直接编译所生成的文件;及
    所述获取模块,还用于根据所述智能合约编译文件,执行与所述区块链 操作指令对应的操作。
  10. 根据权利要求8所述的装置,其特征在于,还包括编译模块,其中:
    所述获取模块,还用于获取携带有智能合约标识的脚本编译指令;
    所述确定模块,还用于根据所述脚本编译指令确定与所述智能合约标识对应的通信类型;
    所述获取模块,还用于当确定的通信类型为进程间通信时,获取动态库编译信息和与所述智能合约标识对应的智能合约脚本;及
    所述编译模块,用于按照所述动态库编译信息,采用动态库编译方式对所述智能合约脚本进行编译,生成相应的动态链接库文件。
  11. 根据权利要求10所述的装置,其特征在于,所述动态库编译信息包括动态库接口编译信息;所述编译模块,还用于将所述动态库接口编译信息添加至所述智能合约脚本中;及读取所述动态库接口编译信息,采用动态库编译方式根据所述动态库接口编译信息将所述智能合约脚本编译为与动态库匹配的动态链接库文件。
  12. 根据权利要求10所述的装置,其特征在于,所述编译模块,还用于确定所述智能合约脚本所对应的智能合约类型;当所述智能合约类型为源代码形式合约时,调用编译工具,按照所述动态库编译信息,采用动态库编译方式对所述智能合约脚本进行编译,生成相应的动态链接库文件;及将所述动态链接库文件加载至所述区块链节点集群中的各区块链节点。
  13. 根据权利要求10至12任一项所述的装置,其特征在于,还包括:
    接收模块,用于接收代码配置终端发送的智能合约文件;所述智能合约文件包括智能合约脚本和与所述代码配置终端相应的数字签名;
    生成模块,用于根据所述智能合约文件生成相应的签名验证请求;
    发送模块,用于向智能合约平台发送所述签名验证请求;所述签名验证请求用于指示所述智能合约平台对所述智能合约文件中的数字签名进行验证;及
    所述执行模块,还用于当接收到所述智能合约平台反馈的表示签名验证通过的反馈信息时,执行所述获取携带有智能合约标识的脚本编译指令。
  14. 根据权利要求13所述的装置,其特征在于,所述执行模块,还用于当接收到所述智能合约平台反馈的表示签名验证通过的反馈信息时,提取所述反馈信息中的平台数字签名;对所述平台数字签名进行验证;及当所述平台数字签名通过验证后,执行所述获取携带有智能合约标识的脚本编译指令。
  15. 一种计算机设备,包括存储器及一个或多个处理器,所述存储器存储有计算机可读指令,所述计算机可读指令被所述一个或多个处理器执行时, 使得所述一个或多个处理器执行以下步骤:
    当检测到携带有智能合约标识的区块链操作指令时,则确定与所述智能合约标识相应配置的通信类型;
    当所述通信类型为进程间通信时,确定相应的动态文件调用函数;
    通过所述动态文件调用函数,调用与所述智能合约标识对应的动态链接库文件;所述动态链接库文件是通过动态库编译方式,对与所述智能合约标识相应的智能合约脚本进行编译所生成的文件;及
    根据调用的所述动态链接库文件,执行与所述区块链操作指令对应的操作。
  16. 根据权利要求15所述的计算机设备,其特征在于,所述处理器执行所述计算机可读指令时还执行以下步骤:
    当所述通信类型为进程内通信时,获取与所述智能合约标识对应的智能合约编译文件;所述智能合约编译文件是对与所述智能合约标识相应的智能合约脚本进行直接编译所生成的文件;及
    根据所述智能合约编译文件,执行与所述区块链操作指令对应的操作。
  17. 根据权利要求15所述的计算机设备,其特征在于,所述处理器执行所述计算机可读指令时还执行以下步骤:
    获取携带有智能合约标识的脚本编译指令;
    根据所述脚本编译指令确定与所述智能合约标识对应的通信类型;
    当确定的通信类型为进程间通信时,获取动态库编译信息和与所述智能合约标识对应的智能合约脚本;及
    按照所述动态库编译信息,采用动态库编译方式对所述智能合约脚本进行编译,生成相应的动态链接库文件。
  18. 一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行以下步骤:
    当检测到携带有智能合约标识的区块链操作指令时,则确定与所述智能合约标识相应配置的通信类型;
    当所述通信类型为进程间通信时,确定相应的动态文件调用函数;
    通过所述动态文件调用函数,调用与所述智能合约标识对应的动态链接库文件;所述动态链接库文件是通过动态库编译方式,对与所述智能合约标识相应的智能合约脚本进行编译所生成的文件;及
    根据调用的所述动态链接库文件,执行与所述区块链操作指令对应的操作。
  19. 根据权利要求18所述的存储介质,其特征在于,所述处理器执行所述计算机可读指令时还执行以下步骤:
    当所述通信类型为进程内通信时,获取与所述智能合约标识对应的智能合约编译文件;所述智能合约编译文件是对与所述智能合约标识相应的智能合约脚本进行直接编译所生成的文件;及
    根据所述智能合约编译文件,执行与所述区块链操作指令对应的操作。
  20. 根据权利要求18所述的存储介质,其特征在于,所述处理器执行所述计算机可读指令时还执行以下步骤:
    获取携带有智能合约标识的脚本编译指令;
    根据所述脚本编译指令确定与所述智能合约标识对应的通信类型;
    当确定的通信类型为进程间通信时,获取动态库编译信息和与所述智能合约标识对应的智能合约脚本;及
    按照所述动态库编译信息,采用动态库编译方式对所述智能合约脚本进行编译,生成相应的动态链接库文件。
PCT/CN2019/122856 2019-05-21 2019-12-04 智能合约调用方法、装置、设备和存储介质 WO2020233092A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910424301.X 2019-05-21
CN201910424301.XA CN110221837A (zh) 2019-05-21 2019-05-21 智能合约调用方法、装置、设备和存储介质

Publications (1)

Publication Number Publication Date
WO2020233092A1 true WO2020233092A1 (zh) 2020-11-26

Family

ID=67821435

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/122856 WO2020233092A1 (zh) 2019-05-21 2019-12-04 智能合约调用方法、装置、设备和存储介质

Country Status (2)

Country Link
CN (1) CN110221837A (zh)
WO (1) WO2020233092A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113805889A (zh) * 2021-08-27 2021-12-17 成都质数斯达克科技有限公司 一种智能合约调用执行方法、装置、设备及可读存储介质

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110221837A (zh) * 2019-05-21 2019-09-10 深圳壹账通智能科技有限公司 智能合约调用方法、装置、设备和存储介质
CN110609679B (zh) * 2019-09-17 2024-04-02 腾讯科技(深圳)有限公司 数据处理方法、装置、计算机可读存储介质和计算机设备
CN110855777B (zh) * 2019-11-12 2022-09-13 腾讯科技(深圳)有限公司 一种基于区块链的节点管理方法及装置
CN111026461B (zh) * 2019-12-06 2022-04-22 联想(北京)有限公司 用于区块链系统的数据处理方法、装置和电子设备
CN111221904A (zh) * 2019-12-23 2020-06-02 深圳壹账通智能科技有限公司 智能合约部署、执行方法、装置、电子设备及存储介质
CN111324396B (zh) * 2020-03-19 2023-09-15 深圳市迅雷网络技术有限公司 一种区块链智能合约执行方法、装置及设备
CN112015399A (zh) * 2020-08-31 2020-12-01 京东数字科技控股股份有限公司 一种生成智能合约的数据处理方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160217019A1 (en) * 2012-06-20 2016-07-28 Mobile Iron, Inc. Partitioned application environment
CN108665253A (zh) * 2018-05-18 2018-10-16 百度在线网络技术(北京)有限公司 一种区块链网络的数据处理方法、装置、设备及存储介质
CN109032706A (zh) * 2018-07-16 2018-12-18 百度在线网络技术(北京)有限公司 智能合约执行方法、装置、设备和存储介质
CN109542767A (zh) * 2018-10-25 2019-03-29 平安科技(深圳)有限公司 基于区块链的自动化测试方法、装置、计算机设备和存储介质
CN110221837A (zh) * 2019-05-21 2019-09-10 深圳壹账通智能科技有限公司 智能合约调用方法、装置、设备和存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160217019A1 (en) * 2012-06-20 2016-07-28 Mobile Iron, Inc. Partitioned application environment
CN108665253A (zh) * 2018-05-18 2018-10-16 百度在线网络技术(北京)有限公司 一种区块链网络的数据处理方法、装置、设备及存储介质
CN109032706A (zh) * 2018-07-16 2018-12-18 百度在线网络技术(北京)有限公司 智能合约执行方法、装置、设备和存储介质
CN109542767A (zh) * 2018-10-25 2019-03-29 平安科技(深圳)有限公司 基于区块链的自动化测试方法、装置、计算机设备和存储介质
CN110221837A (zh) * 2019-05-21 2019-09-10 深圳壹账通智能科技有限公司 智能合约调用方法、装置、设备和存储介质

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113805889A (zh) * 2021-08-27 2021-12-17 成都质数斯达克科技有限公司 一种智能合约调用执行方法、装置、设备及可读存储介质

Also Published As

Publication number Publication date
CN110221837A (zh) 2019-09-10

Similar Documents

Publication Publication Date Title
WO2020233092A1 (zh) 智能合约调用方法、装置、设备和存储介质
WO2020253061A1 (zh) 页面生成方法、装置、计算机设备和存储介质
CN109474578B (zh) 报文消息校验方法、装置、计算机设备和存储介质
CN109788032B (zh) 镜像文件的获取方法、装置、计算机设备和存储介质
CN109492983B (zh) 基于区块链智能合约的电子印章签署方法、装置、设备和介质
CN111314306A (zh) 接口访问方法及装置、电子设备、存储介质
CN110543510B (zh) 票据数据处理方法、装置、存储介质和计算机设备
CN109144487B (zh) 进件业务开发方法、装置、计算机设备和存储介质
CN110008665B (zh) 一种区块链的权限控制方法及装置
CN110633160A (zh) 接口调用方法、装置、计算机设备和存储介质
CN110083384B (zh) 应用程序编程接口创建方法以及装置
WO2020199594A1 (zh) 业务组件加载方法、装置、计算机设备和存储介质
CN111563365B (zh) 试验标准工单修改信息处理方法、装置和计算机设备
CN110609679A (zh) 数据处理方法、装置、计算机可读存储介质和计算机设备
CN113835713B (zh) 源码包下载方法、装置、计算机设备和存储介质
CN112860778B (zh) 桌面应用程序的数据库管理方法、装置、设备和介质
CN111090581A (zh) 智能合约测试方法、装置、计算机设备和存储介质
CN112364049A (zh) 数据同步脚本生成方法、系统、终端及存储介质
CN114118971A (zh) 基于云原生的在线开发方法、装置、设备及存储介质
CN112800393A (zh) 授权认证、软件开发工具包生成方法、装置及电子设备
CN112632573A (zh) 智能合约执行方法、装置、系统、存储介质及电子设备
WO2022110675A1 (zh) 基于人工智能的日志生成方法、装置、计算机设备和介质
CN114268638A (zh) 区块链平台通道管理方法、装置、计算机设备和存储介质
WO2021169469A1 (zh) 声纹数据处理方法、装置、计算机设备和存储介质
CN112862449A (zh) 结构化工单生成方法、装置、计算机设备和存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19929496

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 04/03/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 19929496

Country of ref document: EP

Kind code of ref document: A1