Data processing method, device and equipment based on block chain and readable storage medium
By enabling smart contracts to detect and verify supported interfaces through a designated detection interface, the method improves the reliability and interoperability of smart contract interactions in blockchain systems.
Patent Information
- Application Number
- CN202310665874.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-06
- Publication Date
- 2024-12-06
AI Technical Summary
Smart contracts in blockchain systems often fail to accurately determine whether another smart contract supports a specific interface, leading to incorrect execution of business logic and reduced reliability in data interactions.
Implement a method for smart contracts to support a designated detection interface with an interface detection function, allowing them to verify if another smart contract supports a specific interface by performing logical operations on an interface identifier, and returning the interface attributes to ensure accurate interaction.
Enhances the reliability of smart contract interactions by ensuring accurate detection of supported interfaces, reducing incorrect executions and improving interoperability and scalability within blockchain systems.
Smart Images

Figure CN119089456A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a blockchain-based data processing method, device, equipment, and readable storage medium. Background Art
[0002] With the rapid development of blockchain technology, many business systems currently use blockchain to store relevant business data. Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism and encryption algorithm. It is mainly used to organize data in chronological order and encrypt it into a ledger to make it impossible to be tampered with or forged. At the same time, it can verify, store and update data.
[0003] Different smart contracts can be deployed in the blockchain. Smart contracts can be understood as a code that can be understood and executed by each node of the blockchain (such as business nodes, consensus nodes, etc.). It can execute any logic and get results. For each smart contract in the blockchain, in many business scenarios, it is necessary to interact with other smart contracts or external systems. For example, a smart contract needs to call another smart contract to get a certain result. Taking smart contract A and smart contract B as an example, suppose smart contract A needs to call smart contract B to let smart contract B execute method C to get a certain result. However, when smart contract A calls smart contract B and expects smart contract B to execute method C, smart contract B may not support interface D. Since method C is included in interface D, it means that smart contract B does not implement method C. At this time, smart contract B cannot execute the logic corresponding to method C. Then smart contract B is likely to execute a fault-tolerant fallback method (such as fallback method) and return a successful execution result value to smart contract A.
[0004] It can be seen that at this time, smart contract A cannot know whether the received result value is the accurate result value obtained by smart contract B through executing method C. In other words, smart contract A cannot clearly know whether smart contract B implements interface D (or whether it implements method C). The result value returned by smart contract B is likely to be wrong. Smart contract A cannot determine the accuracy of the result value returned by smart contract B. Smart contract A is likely to incorrectly execute subsequent business logic based on the inaccurate result value and obtain an incorrect result. In other words, how to accurately detect whether a smart contract supports a specific interface (method) to improve the reliability of data interaction between smart contracts is a problem that needs to be solved urgently. Summary of the invention
[0005] The embodiments of the present application provide a blockchain-based data processing method, apparatus, device, and readable storage medium, which can accurately detect the interfaces supported by smart contracts, thereby improving the reliability of the interactive services of smart contracts.
[0006] On the one hand, an embodiment of the present application provides a data processing method based on blockchain, including:
[0007] The first smart contract receives an interface detection request sent by the second smart contract; the first smart contract supports a specified detection interface, and the specified detection interface includes an interface detection function; the interface detection request includes an interface identifier of the interface to be detected;
[0008] Through the function logic indicated by the interface detection function, a logical operation is performed on the interface identifier of the interface to be detected to obtain the interface attribute of the first smart contract for the interface to be detected;
[0009] The interface properties of the first smart contract for the interface to be detected are returned to the second smart contract, so that the second smart contract can interact with the first smart contract through the interface to be detected.
[0010] On the one hand, an embodiment of the present application provides a data processing device based on blockchain, including:
[0011] A request receiving module, used to receive an interface detection request sent by the second smart contract; the first smart contract supports a specified detection interface, and the specified detection interface includes an interface detection function; the interface detection request includes an interface identifier of the interface to be detected;
[0012] A logic operation module, used to perform a logic operation on the interface identifier of the interface to be detected through the function logic indicated by the interface detection function, so as to obtain the interface attribute of the first smart contract for the interface to be detected;
[0013] The attribute return module is used to return the interface attribute of the first smart contract for the interface to be detected to the second smart contract, so that the second smart contract can interact with the first smart contract through the interface to be detected.
[0014] In one embodiment, the blockchain-based data processing device may further include:
[0015] A receiving module, used to receive a function trial execution request sent by the second smart contract; the function trial execution request is used to request the first smart contract to try to execute the interface detection function contained in the specified detection interface, and the function trial execution request includes the interface identifier of the specified detection interface;
[0016] A trial execution module, used to perform a trial execution on the interface detection function based on the interface identifier of the specified detection interface to obtain a trial execution result;
[0017] The execution result returning module is used to return the trial execution result to the second smart contract, so that the second smart contract can detect and process the interface properties of the first smart contract for the specified detection interface based on the trial execution result.
[0018] In one embodiment, the trial execution result is a trial execution success result;
[0019] The blockchain-based data processing device may also include:
[0020] A call request receiving module, used to receive a first function call request sent by the second smart contract based on a successful trial execution result; the first function call request is used to request the first smart contract to call an interface detection function, and the first function call request includes specific detection parameters for detecting a specified detection interface;
[0021] The parameter operation module is used to perform a logic operation on a specific detection parameter through the function logic indicated by the interface detection function to obtain a logic operation result corresponding to the specific detection parameter;
[0022] The operation result returning module is used to return the logic operation result to the second smart contract, so that when the second smart contract determines that the logic operation result is a specific operation result corresponding to the specific detection parameter, it determines that the interface attribute of the first smart contract for the specified detection interface is an interface support attribute.
[0023] In one embodiment, after the interface properties of the interface to be detected by the first smart contract are returned to the second smart contract, the second smart contract is used to analyze the interface properties of the interface to be detected, and when it is determined that the interface properties of the interface to be detected are interface support properties, data is interacted with the first smart contract through the interface to be detected.
[0024] In one embodiment, the function logic indicated by the interface detection function is a first function logic;
[0025] The logic operation module performs a logic operation on the interface identifier of the interface to be detected through the function logic indicated by the interface detection function, and obtains a specific implementation method of the first smart contract for the interface attribute of the interface to be detected, including:
[0026] Obtain a support interface set corresponding to the first smart contract through the first function logic; the interface attributes of each support interface in the support interface set of the first smart contract are all interface support attributes;
[0027] Get the supported interface identifier set corresponding to the supported interface set; a supported interface identifier in the supported interface identifier set refers to an interface identifier of a supported interface in the supported interface set;
[0028] Based on the interface identifier of the interface to be detected, the supported interface identifier set is traversed to obtain a traversal result, and the interface attribute of the first smart contract for the interface to be detected is determined according to the traversal result.
[0029] In one embodiment, the logic operation module determines the specific implementation method of the interface attribute of the first smart contract for the interface to be detected according to the traversal result, including:
[0030] If the traversal result indicates that there is a supported interface identifier that is the same as the interface identifier of the interface to be detected in the supported interface identifier set, then the interface attribute of the first smart contract for the interface to be detected is determined to be an interface support attribute;
[0031] If the traversal result indicates that there is no supported interface identifier that is the same as the interface identifier of the interface to be detected in the supported interface identifier set, it is determined that the interface attribute of the first smart contract for the interface to be detected is an interface unsupported attribute.
[0032] In one embodiment, the function logic indicated by the interface detection function is a second function logic;
[0033] The logic operation module performs a logic operation on the interface identifier of the interface to be detected through the function logic indicated by the interface detection function, and obtains a specific implementation method of the first smart contract for the interface attribute of the interface to be detected, including:
[0034] Through the second function logic, an interface mapping table corresponding to the first smart contract is obtained; the interface mapping table includes a mapping relationship between an existing interface set and an interface attribute value set; there is a mapping relationship between an existing interface in the existing interface set and an interface attribute value in the interface attribute value set; the existing interface set includes an interface to be detected;
[0035] In the interface attribute value set, the interface attribute value corresponding to the interface to be detected is obtained, the interface attribute value corresponding to the interface to be detected is analyzed, and the interface attribute of the first smart contract for the interface to be detected is determined.
[0036] In one embodiment, the logic operation module analyzes the interface attribute value corresponding to the interface to be detected, and determines the specific implementation method of the first smart contract for the interface attribute of the interface to be detected, including:
[0037] Analyze the interface attribute value corresponding to the interface to be detected to obtain the analysis result;
[0038] If the analysis result indicates that the interface attribute value corresponding to the interface to be detected is the attribute value corresponding to the interface support attribute, then it is determined that the interface attribute of the first smart contract for the interface to be detected is the interface support attribute;
[0039] If the analysis result indicates that the interface attribute value corresponding to the interface to be detected is the attribute value corresponding to the interface not supported attribute, it is determined that the interface attribute of the first smart contract for the interface to be detected is the interface not supported attribute.
[0040] In one embodiment, before the logic operation module performs a logic operation on the interface identifier of the interface to be detected through the function logic indicated by the interface detection function to obtain the interface attribute of the first smart contract for the interface to be detected, the blockchain-based data processing device may further include:
[0041] An interface set acquisition module, used to acquire a support interface set corresponding to the first smart contract; the interface attributes of each support interface in the support interface set of the first smart contract are all interface support attributes;
[0042] A quantity statistics module is used to count the number of interfaces of the supported interfaces contained in the supported interface set;
[0043] A quantity analysis module, used for performing quantity analysis on the number of interfaces based on a quantity threshold;
[0044] The logic determination module is used to determine the function logic indicated by the interface detection function in the configuration function logic set corresponding to the interface detection function based on the quantity analysis result.
[0045] In one embodiment, the logic determination module determines the specific implementation of the function logic indicated by the interface detection function in the configuration function logic set corresponding to the interface detection function based on the quantity analysis result, including:
[0046] If the quantity analysis result is a first quantity analysis result indicating that the number of interfaces is greater than the quantity threshold, obtaining a first function logic indicated by the first quantity analysis result in the configuration function logic set, and determining the first function logic as the function logic indicated by the interface detection function;
[0047] If the quantity analysis result is a second quantity analysis result indicating that the number of interfaces is greater than the quantity threshold, in the configuration function logic set, a second function logic indicated by the second quantity analysis result is obtained, and the second function logic is determined as the function logic indicated by the interface detection function.
[0048] In one embodiment, the interface attribute of the first smart contract for the interface to be detected is an interface support attribute;
[0049] After the attribute return module returns the interface attribute of the first smart contract for the interface to be detected to the second smart contract, the blockchain-based data processing device may further include:
[0050] A function request receiving module, used to receive a second function call request for a target function sent by a second smart contract; the target function is a function included in the interface to be detected, and the second function call request for the target function includes an interaction parameter;
[0051] An operation module, used to execute the target function logic indicated by the target function based on the second function call request, perform parameter operation on the interaction parameter through the target function logic, and obtain the parameter operation result corresponding to the interaction parameter;
[0052] The parameter result return module is used to return the parameter operation result to the second smart contract.
[0053] An embodiment of the present application provides a computer device, including: a processor and a memory;
[0054] The memory stores a computer program, and when the computer program is executed by the processor, the processor executes the method in the embodiment of the present application.
[0055] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program includes program instructions. When the program instructions are executed by a processor, the method in the embodiment of the present application is executed.
[0056] In one aspect of the present application, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the method provided in one aspect of the embodiments of the present application.
[0057] In an embodiment of the present application, the first smart contract can realize a designated detection interface so that when the second smart contract calls a specific interface (such as the interface to be detected) in the first smart contract, it first detects the interface to be detected through the interface detection function in the designated detection interface implemented by the first smart contract to detect whether the first smart contract has implemented the interface to be detected. After clarifying that the first smart contract has implemented the interface to be detected, the second smart contract can call the interface to be detected implemented by the first smart contract to interact with the first smart contract. This can reduce the situation where the first smart contract cannot execute or incorrectly executes logic after the second smart contract calls a certain interface in the first smart contract, thereby improving the reliability of the interaction between the first smart contract and the second smart contract. In summary, the present application can accurately detect the interfaces supported by smart contracts, thereby improving the reliability of the interactive services of smart contracts. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0059] Figure 1 This is a network architecture diagram provided by an embodiment of the present application;
[0060] Figure 2 It is a flowchart of a data processing method based on blockchain provided in an embodiment of the present application;
[0061] Figure 3 It is a flow chart of detecting the interface attributes of an interface to be detected by using an interface detection function provided by an embodiment of the present application;
[0062] Figure 4 It is another flow chart of detecting the interface attributes of the interface to be detected by using the interface detection function provided by the embodiment of the present application;
[0063] Figure 5 It is a structural schematic diagram of a blockchain-based data processing device provided in an embodiment of the present application;
[0064] Figure 6 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0065] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0066] The method provided in the embodiment of the present application involves blockchain and other related technologies. For ease of understanding, the following will give priority to blockchain and its related technologies:
[0067] 1. Blockchain: In a narrow sense, blockchain is a chain data structure with blocks as the basic unit. The digital summary is used in the block to verify the transaction history previously obtained, which is suitable for the needs of tamper-proof and scalability in the distributed accounting scenario; in a broad sense, blockchain also refers to the distributed accounting technology implemented by the blockchain structure, including distributed consensus, privacy and security protection, peer-to-peer communication technology, network protocols, smart contracts, etc. The goal of the blockchain is to realize a distributed data record book, which only allows additions but not deletions. The basic structure of the underlying ledger is a linear linked list. The linked list is composed of "blocks" connected in series, and the hash value of the previous block is recorded in the subsequent block. Whether each block (and the transactions in the block) is legal can be quickly verified by calculating the hash value. If a node in the network proposes to add a new block, it must reach a consensus on the block through the consensus mechanism.
[0068] 2. Blockchain nodes: The blockchain network divides nodes into consensus nodes (also called core nodes), data nodes or light nodes. Among them, the consensus node is responsible for the consensus business of the entire blockchain network; the data node or light node is responsible for synchronizing the ledger information of the consensus node, that is, synchronizing the latest block data. Whether it is a consensus node or a data node (or light node), its internal structure includes network communication components, because the blockchain network is essentially a peer-to-peer (P2P) network, and it needs to communicate with other nodes in the blockchain network through P2P components. The resources and services in the blockchain network are scattered on each node, and the transmission of information and the implementation of services are directly carried out between nodes, without the intervention of intermediate links or centralized servers (third parties).
[0069] 3. Public key and private key: Public key and private key are a key pair (i.e., a public key and a private key) obtained through an algorithm. The public key is the public part of the key pair, and the private key is the non-public part. The public key is usually used to encrypt data, verify digital signatures, etc. This algorithm can ensure that the key pair obtained is unique. When using this key pair, if one of the keys is used to encrypt a piece of data, the other key must be used to decrypt it. For example, if the data is encrypted with the public key, it must be decrypted with the private key. If it is encrypted with the private key, it must also be decrypted with the public key, otherwise the decryption will not be successful.
[0070] 4. Hash value: Also known as information characteristic value or characteristic value, hash value is generated by converting input data of any length into a password and performing fixed output through a hash algorithm. The original input data cannot be retrieved by decrypting the hash value. It is a one-way encryption function. In the blockchain, each block (except the initial block) contains the hash value of the previous block, which is called the parent block of the current block. Hash value is the potential core foundation and the most important aspect of blockchain technology. It preserves the authenticity of recorded and viewed data, as well as the integrity of the blockchain as a whole.
[0071] 5. Smart Contract: It is a computer protocol designed to disseminate, verify or execute contracts in an information-based manner. In the blockchain system, a smart contract (referred to as a contract) is a code that can be understood and executed by each node of the blockchain, which can execute any logic and obtain results. In practical applications, smart contracts are managed and tried through transactions on the blockchain. Each transaction is equivalent to a remote procedure call (RPC) request to the blockchain system. If a smart contract is equivalent to an executable program, the blockchain is equivalent to an operating system that provides an operating environment. The blockchain can contain multiple contracts, which are distinguished by contract accounts (Identity, ID), identification numbers or names. For example, a smart contract can include a governance consensus committee contract, which is mainly used to manage consensus nodes, and can include recording the node status of consensus nodes, dynamically adding consensus nodes, and removing abnormal consensus nodes.
[0072] See also Figure 1 , Figure 1 This is a network architecture diagram provided by an embodiment of the present application. Figure 1 As shown, the network architecture may include a terminal device cluster 10 and a blockchain network, and the blockchain network may include a core node (consensus node) cluster 1000 and a data node or light node cluster 100. The core node cluster 1000 may include at least two core nodes, and the data node cluster 100 may include at least two data nodes. Figure 1 As shown, the core node cluster 1000 may include core node 1000a, core node 1000b, ..., core node 1000n, the data node cluster 100 may specifically include data node 100a, data node 100b, ..., data node 100n, and the terminal device cluster 10 may specifically include terminal device 10a, terminal device 10b, ..., terminal device 10n.
[0073] like Figure 1As shown, terminal device 10a, terminal device 10b, ..., terminal device 10n can respectively establish network connection with data node 100a, data node 100b, ..., data node 100n, so that the terminal device can exchange data with the data node through the network connection; data node 100a, data node 100b, ..., data node 100n can respectively establish network connection with core node 1000a, core node 1000b, ..., core node 1000n, so that the data node can exchange data with the core node through the network connection; data node 100a, data node 100b, ..., data node 100n are connected to each other, so that data nodes can exchange data with each other, and core node 1000a, core node 1000b, ..., core node 1000n are connected to each other, so that core nodes can exchange data with each other.
[0074] Taking the terminal device 10a, the data node 100a and the core node 1000a as an example, the data node 100a can receive a transaction service request sent by the terminal device 10a (the transaction service request carries the ID or name of the smart contract), and then the data node 100a can send the transaction service request to the core node 1000a through the data node cluster 100; the core node 1000a can run the smart contract and execute the transaction service through the smart contract. After obtaining the execution result, the execution result can be stored in the memory pool (such as the transaction pool), and a new block can be generated according to the execution result; then, the core node 1000a can send the newly generated blocks to other core nodes in the blockchain network where it is located according to the node identifiers of other core nodes (i.e., consensus nodes) in the blockchain network, and other core nodes will verify the newly generated blocks (i.e., reach consensus), and add the newly generated blocks to the blockchain stored thereafter (that is, the execution results are stored in the blockchain after the consensus is passed). Among them, each core node in the blockchain network has a corresponding node identifier, and each core node in the blockchain network can store the node identifiers of other core nodes in the blockchain network, so that the generated blocks can be broadcast to other core nodes in the blockchain network according to the node identifiers of other core nodes, so that the data stored on all core nodes in the blockchain network are consistent.
[0075] Among them, Figure 1The terminal device shown can be a desktop terminal or mobile terminal used by the business party that generates transaction information, and can be a smart terminal with data processing functions such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart TV, a smart speaker, a desktop computer, a smart watch, a smart car terminal, etc., but is not limited to this. The transaction information (transaction data) generated by the terminal device can be transmitted to the consensus node via a data node or a light node after user authorization, and the consensus node can record the transaction information (transaction data) generated by the terminal device on the blockchain. Any data node in the data node cluster 100 can be implemented with an independent server or a server cluster composed of multiple servers, and any core node in the core node cluster 1000 can be implemented with an independent server or a server cluster composed of multiple servers.
[0076] Taking the terminal device 10a, the data node 100a and the core node 1000a as an example, the data node 100a can receive a transaction service request sent by the terminal device 10a (the transaction service request carries the ID or name of the smart contract), and then the data node 100a can send the transaction service request to the core node 1000a through the data node cluster 100; the core node 1000a can run the smart contract and execute the transaction service through the smart contract. After obtaining the execution result, the execution result can be stored in the memory pool (such as the transaction pool), and a new block can be generated according to the execution result; then, the core node 1000a can send the newly generated blocks to other core nodes in the blockchain network where it is located according to the node identifiers of other core nodes (i.e., consensus nodes) in the blockchain network, and other core nodes will verify the newly generated blocks (i.e., reach consensus), and add the newly generated blocks to the blockchain stored thereafter (that is, the execution results are stored in the blockchain after the consensus is passed). Among them, each core node in the blockchain network has a corresponding node identifier, and each core node in the blockchain network can store the node identifiers of other core nodes in the blockchain network, so that the generated blocks can be broadcast to other core nodes in the blockchain network according to the node identifiers of other core nodes, so that the data stored on all core nodes in the blockchain network are consistent.
[0077] For smart contracts in blockchain, it can be understood as a code that can be understood and executed by each node of blockchain (such as business node, consensus node, etc.), which can execute arbitrary logic and obtain results. When a smart contract or external system expects to interact with a smart contract, it can interact with the smart contract by calling the smart contract. In this application, in order to improve the reliability and security of the interactive business of smart contracts (such as interaction between smart contracts, interaction between smart contracts and external systems), this application proposes a smart contract interface detection method. Through the method provided by this application, the interface supported by the smart contract can be accurately detected before calling the smart contract, so that the method in the specific interface of the smart contract can be called after the smart contract supports a specific interface. Specifically, in this application, if it is expected that an external system or another smart contract can detect the interface supported by a smart contract, then the smart contract to be detected must first implement support for a specified detection interface (such as Detection interface), and the Detection interface contains an interface detection function (such as supportsInterface function) for detecting a specific interface. It can be understood that the designated detection interface can be a preset interface, and the interface detection function contained in the designated detection interface can include a preset logic for interface detection (that is, the function logic indicated by the interface detection function can be preset). Then, when other smart contracts (such as smart contract A) or external systems expect to detect whether a specific interface is implemented and supported in the smart contract (such as smart contract B), other smart contracts (smart contract A) or external systems can call the interface detection function in the smart contract (smart contract B). Smart contract B can determine whether the specific interface is implemented and supported in smart contract B by executing the function logic of the interface detection function. If smart contract B does implement the specific interface, then the smart contract A or the external system can subsequently interact with smart contract B through the specific interface.
[0078] For ease of understanding, taking the example of the second smart contract expecting to detect whether a specific interface is supported in the first smart contract (in this application, a specific interface to be detected may be referred to as the interface to be detected), assuming that the first smart contract has implemented the specified detection interface, that is, the first smart contract supports the specified detection interface. At this time, the second smart contract can send an interface detection request for the interface to be detected to the first smart contract, and attach an interface identifier for the interface to be detected to the interface detection request (wherein, the interface identifier may refer to an identifier used to uniquely characterize the interface to be detected, and the interface identifier may be specifically generated based on the method / function contained in the interface to be detected. For the method of determining the interface identifier, please refer to the subsequent description); subsequently, after receiving the interface detection request sent by the second smart contract, the first smart contract , the interface identifier of the interface to be detected can be logically operated by specifying the function logic indicated by the interface detection function contained in the detection interface, and the interface attribute of the first smart contract for the interface to be detected can be determined based on the logical operation result obtained by the logical operation, wherein the interface attribute of the first smart contract for the interface to be detected can be an interface support attribute or an interface unsupported attribute. When the interface attribute of the first smart contract for the interface to be detected is an interface support attribute, it can be explained that the first smart contract has implemented the interface to be detected and the first smart contract supports the interface to be detected; and when the interface attribute of the first smart contract for the interface to be detected is an interface unsupported attribute, it can be explained that the first smart contract has not implemented the interface to be detected and the first smart contract does not support the interface to be detected.
[0079] Furthermore, the first smart contract can return the interface attribute of the first smart contract for the interface to be detected to the second smart contract. When the second smart contract determines that the interface attribute of the interface to be detected is an interface support attribute, it can interact with the first smart contract through the interface to be detected. For example, the second smart contract can call the function contained in the interface to be detected (for the sake of distinction, it is referred to as the target function here). Since the first smart contract supports the interface to be detected, the first smart contract can execute the function logic known by the target function, thereby obtaining a result value, and the first smart contract can return the result value to the second smart contract.
[0080] It should be understood that the first smart contract can make the second smart contract, by implementing the specified detection interface, detect the interface to be detected by the interface detection function in the specified detection interface implemented by the first smart contract when calling the specific interface (such as the interface to be detected) in the first smart contract, so as to detect whether the first smart contract has implemented the interface to be detected. After clarifying that the first smart contract has implemented the interface to be detected, the second smart contract can call the target function in the interface to be detected implemented by the first smart contract to interact with the first smart contract. This can reduce the situation where the first smart contract cannot execute or incorrectly executes the function logic after calling a certain interface in the first smart contract, thereby improving the reliability of the interaction between the first smart contract and the second smart contract, and also improving the interoperability and scalability of the smart contract, and promoting the development of blockchain. In other words, by the method proposed in this application to detect whether the smart contract supports a specific interface based on the specified detection interface, the reliability of the interactive business of the smart contract can be improved, and the interoperability and scalability of the smart contract can also be improved, thereby promoting the development of blockchain.
[0081] It is understood that the terminal device in the present application may include a smart phone, tablet computer, laptop computer, desktop computer and other intelligent terminals with data processing functions. The terminal device may be installed with a target application (i.e., an application client). When the application client runs in the terminal device, it can be used with the above-mentioned Figure 1 Data is exchanged between other blockchain nodes in the blockchain network shown. Among them, the application client may include social clients, multimedia clients (for example, video clients), entertainment clients (for example, game clients), education clients, live broadcast clients and other application clients. Among them, the application client can be an independent client, or it can be an embedded sub-client integrated in a client (for example, a social client, an education client, and a multimedia client, etc.), which is not limited here. The blockchain node in this application may refer to a server, and the server can exchange data with the terminal device through the application in the terminal device. The server here can be an independent physical server, or it can be a server cluster or distributed system composed of multiple physical servers, or it can be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and basic cloud computing services such as big data and artificial intelligence platforms.
[0082] It is understandable that the method provided in the embodiment of the present invention can be executed by a computer device, including but not limited to a terminal device or a server. The blockchain node in the embodiment of the present invention can be a computer device (that is, a terminal device can also be a blockchain node).
[0083] It should be noted that in the specific implementation of the present application, data related to user information, user data (such as transaction data generated by users in the application client of the terminal device), etc., all require manual authorization and permission from the user (that is, with the user's consent) before they can be obtained. In other words, when the above embodiments of the present application are applied to specific products or technologies, the methods and related functions provided by the embodiments of the present application are operated with the permission or consent of the user (the user can actively enable the functions provided by the embodiments of the present application), and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0084] For ease of understanding, the following will describe in detail the blockchain-based data processing method provided by the embodiment of the present application in conjunction with the accompanying drawings. Figure 2 , Figure 2 This is a flowchart of a data processing method based on blockchain provided by an embodiment of the present application. The method can be executed by a blockchain node (the blockchain node can be the above-mentioned data node, core node, etc.), and can be specifically executed by a smart contract deployed in the blockchain. For ease of understanding, this embodiment takes the execution of the method by the first smart contract (a smart contract deployed in the blockchain) as an example for explanation. Figure 2 As shown, the blockchain-based data processing method may at least include the following steps S101-S103:
[0085] Step S101, the first smart contract receives an interface detection request sent by the second smart contract; the first smart contract supports a specified detection interface, and the specified detection interface includes an interface detection function; the interface detection request includes an interface identifier of the interface to be detected.
[0086] In this application, the first smart contract and the second smart contract may refer to two different smart contracts in the blockchain. If the first smart contract implements a specified detection interface (i.e., the first smart contract supports the specified detection interface), then the second smart contract can detect whether the first smart contract implements a specific interface based on the interface detection function in the specified detection interface (the specific interface that the second smart contract expects to detect may be referred to as the interface to be detected).
[0087] Among them, the interface detection function here may refer to a function used to detect the interface supported by the smart contract (that is, the interface detection function is used to detect whether the smart contract implements a certain interface). The interface detection function in this application may specifically be a supportsInterface function (that is, the sopportsInterface method). The supportsInterface function needs to pass in a specified byte (such as 4 bytes) of interface identifier (that is, interfaceID) as a parameter. Through the function logic indicated by the supportsInterface function, the interface identifier passed in can be operated, so as to obtain an operation result. By analyzing the operation result, it can be determined whether the first smart contract supports the interface. Correspondingly, the designated detection interface here may refer to an interface that includes the interface detection function. Specifically, the designated detection interface in this application may refer to the Detection interface.
[0088] To facilitate understanding of the specified detection interface and interface detection function, please refer to Table 1, which is the specific code implementation of the Detection interface in this application, as shown in Table 1:
[0089] Table 1
[0090]
[0091] Among them, as shown in Table 1, interface can refer to the declaration of the interface, function can refer to the declaration of the method contained in the interface, and the Detection interface can refer to the specified detection interface in this application. The Detection interface contains a supportsInterface method (i.e., the interface detection function in this application), and the supportsInterface method needs to pass in a 4-byte (byte4) interfaceID (an interfaceID can refer to the interface identifier of an interface to be detected) as a parameter, and the supportsInterface method can operate on the parameter to obtain an operation result (the operation result can specifically be a Boolean value, through which it can be reflected whether the interface indicated by the interfaceID is implemented in the smart contract). As shown in Table 1, external can mean that the supportsInterface method can be called externally (i.e., when the smart contract implements the Detection interface, the external system or other smart contracts can call the supportsInterface method in the Detection interface); as shown in Table 1, view is used to indicate that the supportsInterface method is a read-only method (i.e., the method will not modify the data of the smart contract); as shown in Table 1, returns can be used to indicate that the value returned by the method is a Boolean value.
[0092] It can be understood that when the first smart contract supports the specified detection interface, the interface detection function in the specified detection interface can be called externally to detect whether a specific interface is supported in the first smart contract. Then for the second smart contract, if the second smart contract expects to detect whether the first smart contract supports a specific interface (that is, to detect the interface properties of the first smart contract for the specific interface, the specific interface that the second smart contract expects to detect can be called the interface to be detected), then the second smart contract can call the interface detection function in the specified detection interface, and pass in the interface identifier of the interface to be detected as the input parameter of the interface detection function, and the first smart contract can execute the function logic of the interface detection function, and operate on the input parameter (that is, the interface identifier of the interface to be detected), thereby determining whether the first smart contract supports the interface to be detected (that is, determining the interface properties of the first smart contract for the interface to be detected).
[0093] It should be understood that in order to improve the reliability of the interactive services of smart contracts, when the second smart contract is not sure whether the first smart contract supports the specified detection interface, the second smart contract can first detect whether the first smart contract supports the specified detection interface. When it is determined that the first smart contract supports the specified detection interface, the second smart contract can then send an interface detection request containing the interface identifier of the interface to be detected to the first smart contract, requesting to detect whether the first smart contract supports the interface to be detected.
[0094] Specifically, since the second smart contract is not sure whether the first smart contract implements the specified detection interface, the second smart contract can first attempt to call the interface detection function (such as the supportsInterface method) in the first smart contract to detect whether the first smart contract implements the specified detection interface (since the interface detection function is included in the specified detection interface, if the attempted call is successful, it can be reflected that the first smart contract implements the specified detection interface).
[0095] That is to say, the method for detecting whether the first smart contract supports the specified detection interface can be as follows: the second smart contract first sends a function trial execution request for the interface detection function to the first smart contract (that is, a request to try to call the interface detection function, which can be used to request the first smart contract to try to execute the interface detection function contained in the specified detection interface, so the function trial execution request can include the interface identifier of the specified detection interface, and the interface identifier of the specified detection interface can be used as an input parameter of the interface detection function. In other words, the function trial execution request is used to request the first smart contract to try to execute the interface detection function contained in the specified detection interface, and the function trial execution request includes the interface identifier of the specified detection interface), and then the first smart contract can receive the function trial execution request sent by the second smart contract; the first smart contract can perform a trial execution on the interface detection function based on the interface identifier of the specified detection interface, thereby obtaining a trial execution result; wherein, the trial execution result can include a successful trial execution result and a failed trial execution result, and further, the first smart contract can return the trial execution result to the second smart contract, so that the second smart contract can detect and process the interface properties of the first smart contract for the specified detection interface based on the trial execution result. For example, when the trial execution result is a successful trial execution result, the second smart contract can determine that the first smart contract implements the specified detection interface; and when the trial execution result is a failed trial execution result, the second smart contract can determine that the first smart contract does not implement the specified detection interface. In other words, the process by which the second smart contract detects and processes the interface attributes of the first smart contract for the specified detection interface based on the trial execution result can refer to the process of determining whether the first smart contract implements (supports) the specified detection interface. When the trial execution result is a successful trial execution result, the second smart contract can determine that the interface attributes of the first smart contract for the specified detection interface are interface support attributes. When the trial execution result is a failed trial execution result, the second smart contract can determine that the interface attributes of the first smart contract for the specified detection interface are interface non-support attributes.
[0096] Optionally, it is understandable that in order to improve the accuracy of the interface properties of the first smart contract detected for the specified detection interface, after trying to call the interface detection function of the specified detection interface, if the trial execution result returned by the first smart contract to the second smart contract is a successful trial execution result, the second smart contract can set the interface properties of the first smart contract for the specified detection interface as interface support properties, and the second smart contract can call the interface detection function again and pass in a specific detection parameter for detecting the specified detection interface (in this application, the specific detection parameter can be set to 0xffffffff. Of course, in addition to 0xffffffff, it can also be set to other parameters that can be used for interface detection. The specific value of the specific detection parameter is not limited in this application), where it should be noted that for the specific detection parameter, the present application can preset a reasonable operation result value (which can be called a preset specific result value) for the specific detection parameter based on the characteristics of the specific detection parameter and the characteristics of the interface detection parameter. After the interface detection function of the first smart contract performs a logical operation on the specific detection parameter, if the obtained operation result value is the preset reasonable operation result value (preset specific result value), then it can be finally determined that the interface attribute of the first smart contract for the specified detection interface is an interface support attribute; otherwise, it can be finally determined that the interface attribute of the first smart contract for the specified detection interface is an interface unsupported attribute.
[0097] Specifically, that is to say, when the trial execution result is a successful trial execution result, the second smart contract can perform subsequent detection on the interface properties of the first smart contract for the specified detection interface based on specific detection parameters. The specific method can be: when the trial execution result is a successful trial execution result, the second smart contract can send a function call request for the interface detection function to the first smart contract (in order to distinguish it from another subsequent function call request, it can be referred to as the first function call request here. The first function call request is used to request the first smart contract to call the interface detection function, wherein, since the second smart contract is based on specific detection parameters at this time, the first function call request is used to request the first smart contract to call the interface detection function. The first smart contract may receive the first function call request sent by the second smart contract based on the successful result of the trial execution; then, the first smart contract may perform a logical operation on the specific detection parameters through the function logic indicated by the interface detection function, thereby obtaining the logical operation result corresponding to the specific detection parameters; further, the first smart contract may return the logical operation result to the second smart contract, so that when the second smart contract determines that the logical operation result is the specific operation result corresponding to the specific detection parameters, it determines that the interface attribute of the first smart contract for the specified detection interface is the interface support attribute.
[0098] It can be understood that after the first smart contract executes the function logic of the interface detection function and performs logical operations on the specific detection parameters, the obtained logical operation results can be compared with the preset specific result values mentioned above (i.e., the specific operation results corresponding to the specific detection parameters). If the logical operation result is the specific operation result, then the second smart contract can determine that the interface attributes of the first smart contract for the specified detection interface are interface support attributes; otherwise, the second smart contract can determine that the interface attributes of the first smart contract for the specified detection interface are interface unsupported attributes. It should be noted that in the present application, after the interface detection function is logically operated, the operation result value obtained can be a Boolean value. In the present application, the Boolean value can specifically be True or False. When the specific detection parameter is 0xffffffff, the specific operation result preset for the specific detection parameter 0xffffffff can be False. When the specific detection parameter 0xffffffff is logically operated by the interface detection function, if the operation result obtained is the specific operation result False, then the second smart contract can finally determine that the interface attribute of the first smart contract for the specified detection interface is the interface support attribute; correspondingly, when the interface detection function is tried to be executed above, if the first smart contract supports the specified detection interface, then the first smart contract will also execute the function logic of the interface detection function, and the interface detection function can perform logical operations on the interface identifier of the specified detection interface. At this time, if the operation result obtained is True, then the second smart contract can preliminarily determine that the interface attribute of the first smart contract for the specified detection interface is the interface support attribute.
[0099] Step S102: Perform a logical operation on the interface identifier of the interface to be detected through the function logic indicated by the interface detection function to obtain the interface attributes of the first smart contract for the interface to be detected.
[0100] In the present application, after the first smart contract receives the interface detection request sent by the second smart contract and containing the interface identifier of the interface to be detected, the first smart contract can execute the interface detection function in the specified detection interface. Through the function logic of the interface detection function, logical operations can be performed on the interface identifier of the interface to be detected, thereby determining the interface properties of the first smart contract for the interface to be detected.
[0101] It should be understood that for the function logic of the interface detection function, the present application can pre-encode and configure it. Specifically, the present application can pre-encode and configure multiple different function logics for the interface detection function (for the sake of distinction, each encoded and configured function logic can be referred to as a configuration function logic here), thereby obtaining a configuration function logic set. For the function logic of the interface detection function in the actual scenario, it can be selected and determined in the configuration function logic set based on the actual situation.
[0102] That is to say, before executing the function logic indicated by the interface detection function, performing logical operations on the interface identifier of the interface to be detected, and obtaining the interface properties of the first smart contract for the interface to be detected, the first smart contract can first determine the function logic of the interface detection function, and its specific implementation method can be: the supported interface set corresponding to the first smart contract can be obtained; wherein, the interface properties of each supported interface in the supported interface set by the first smart contract are all interface support properties; then, the number of supported interfaces included in the supported interface set can be counted, and the number of interfaces can be quantitatively analyzed based on the quantity threshold, and based on the quantitative analysis results, the function logic indicated by the interface detection function can be determined in the configuration function logic set corresponding to the interface detection function.
[0103] Among them, the specific implementation method of determining the function logic indicated by the interface detection function in the configuration function logic set corresponding to the interface detection function based on the quantity analysis result may be: if the quantity analysis result is a first quantity analysis result indicating that the number of interfaces is greater than the quantity threshold, then in the configuration function logic set, the first function logic indicated by the first quantity analysis result can be obtained, and the first function logic can be determined as the function logic indicated by the interface detection function; and if the quantity analysis result is a second quantity analysis result indicating that the number of interfaces is greater than the quantity threshold, then in the configuration function logic set, the second function logic indicated by the second quantity analysis result can be obtained, and the second function logic can be determined as the function logic indicated by the interface detection function.
[0104] It can be understood that in the present application, for the configuration function logic set of the interface detection function (such as the supportsInterface method), a first function logic may be included (that is, a certain configuration function logic is the first function logic), and the first function logic may refer to traversing and calculating the interface identifiers of all interfaces implemented by the first smart contract (which may include the interface identifier of the specified detection interface, which can be referred to as the support interface identifier for ease of distinction), and whether the interface identifier of the interface to be detected is equal to one of the support interface identifiers. If there is a support interface identifier that is equal to the interface identifier of the interface to be detected, then the remaining interface identifiers can be stopped. The first smart contract compares the supported interface identifiers with the interface identifiers of the interface to be detected, and obtains an operation result value (such as True) used to characterize that the first smart contract supports the interface to be detected. That is to say, when there is a supported interface identifier that is equal to the interface identifier of the interface to be detected, it can be determined that the interface attribute of the first smart contract for the interface to be detected is the interface support attribute (that is, the first smart contract supports the interface to be detected); if all supported interface identifiers are traversed and no supported interface identifier is equal to the interface identifier of the interface to be detected, then it can be determined that the interface attribute of the first smart contract for the interface to be detected is the interface unsupported attribute (that is, the first smart contract does not support the interface to be detected).
[0105] Similarly, for the configuration function logic set of the interface detection function (such as the supportsInterface method), a second function logic may be included (i.e., a certain configuration function logic is the second function logic). The second function logic may mean that the first smart contract may maintain an interface mapping table of different interfaces and interface attribute values (used to reflect the interface attributes of the smart contract for the interface). In the interface mapping table, the interface identifiers of different interfaces may be used as keys, and the interface attribute values corresponding to the interfaces may be used as values. Then, for the interface identifier of the interface to be detected, the corresponding value (value with a mapping relationship) may be obtained in the interface mapping table as a key. If the value is an interface attribute value reflecting that the first smart contract supports the interface to be detected (such as True), the interface detection function may obtain an operation result value (such as True) used to represent that the first smart contract supports the interface to be detected; and if the value is an interface attribute value reflecting that the first smart contract does not support the interface to be detected (such as False), the interface detection function may obtain an operation result value (such as False) used to represent that the first smart contract does not support the interface to be detected. That is to say, the interface mapping table maintains the mapping relationship between different interfaces and interface attribute values. An interface attribute value is used to reflect the interface attribute of the first smart contract for the corresponding interface (that is, to reflect whether the first smart contract supports the corresponding interface). Then, for the interface identifier of the interface to be detected, the corresponding interface attribute value can be found in the interface mapping table, and the interface attribute value of the first smart contract for the interface to be detected can be determined.
[0106] For the first function logic mentioned above, there is no need to store the interface mapping table, which can reduce the resources consumed when deploying the smart contract (such as the resources required for blockchain node calculation), but the resources consumed when calling the interface detection function are not stable enough. As the number of interfaces supported by the contract increases, the resources consumed will also increase. For the second function logic mentioned above, the resources it needs to consume (such as the resources required for blockchain node calculation) are relatively stable, but the interface mapping table needs to be stored when deploying the smart contract, and more resources need to be consumed when storing the interface mapping table. Based on this, the present application can set a function logic selection rule. When the number of interfaces supported by the smart contract is small (that is, the number of interfaces supported by the smart contract is less than the quantity threshold), the first function logic mentioned above can be used as the function logic of the interface detection function, and when the number of interfaces supported by the smart contract is large (that is, the number of interfaces supported by the smart contract is greater than the quantity threshold), the second function logic mentioned above can be used as the function logic of the interface detection function.
[0107] Furthermore, after determining the function logic of the interface detection function, the interface identifier of the interface to be detected can be logically operated through the function logic indicated by the interface detection function to obtain the interface attribute of the first smart contract for the interface to be detected. Figure 3 or Figure 4 The description in the corresponding embodiment.
[0108] Step S103: Return the interface attributes of the first smart contract for the interface to be detected to the second smart contract, so that the second smart contract can interact with the first smart contract through the interface to be detected.
[0109] In the present application, the first smart contract can determine the interface attributes of the first smart contract for the interface to be detected based on the operation result obtained by the interface detection function. Subsequently, the first smart contract can return the interface attributes of the interface to be detected to the second smart contract, and the second smart contract can determine whether the interface attributes of the interface to be detected are interface support attributes or interface non-support attributes. After the second smart contract determines that the interface attributes of the first smart contract for the interface to be detected are interface support attributes, it can interact with the first smart contract through the interface to be detected. That is to say, after the first smart contract returns the interface attributes of the interface to be detected to the second smart contract, the second smart contract can analyze the interface attributes of the interface to be detected, and when it is determined that the interface attributes of the interface to be detected are interface support attributes, it interacts with the first smart contract through the interface to be detected.
[0110] Among them, the data interaction between the second smart contract and the first smart contract can be as follows: the second smart contract can call the method function (which can be called the target function) contained in the interface to be detected and pass in the corresponding parameters, and the first smart contract can execute the target function and obtain a result value, and the first smart contract can return the result value to the second smart contract. Specifically, that is to say, after the interface attributes of the first smart contract for the interface to be detected are returned to the second smart contract, and the second smart contract determines that the interface attributes of the first smart contract for the interface to be detected are interface support attributes, the second smart contract can interact with the first smart contract for data, for example: the second smart contract can send a function call request for the target function (which can be referred to as a second function call request) to the first smart contract, and the first smart contract can receive the second function call request for the target function sent by the second smart contract; wherein, the second function call request for the target function can include interaction parameters (i.e., parameters passed in by the first smart contract); then, the first smart contract can execute the target function logic indicated by the target function based on the second function call request, and the interaction parameters can be operated on by the target function logic, thereby obtaining the parameter operation results corresponding to the interaction parameters; then, the first smart contract can return the parameter operation results to the second smart contract.
[0111] It should be noted that the interface identifier of an interface (such as an interface to be detected, a designated detection interface, etc.) in the present application may refer to an identifier used to uniquely characterize the interface. For example, the interface identifier of the interface to be detected, the interface identifier of a certain interface, can be generated based on the method (function) contained in the interface. The specific generation method can be: first use a method calculator to calculate the method identifier of each method contained in the interface, and then the method identifiers of all methods in the interface can be XORed, and the obtained XOR result can be used as the interface identifier corresponding to the final interface.
[0112] Specifically, the specific implementation method of using a method to calculate the method identifier of a method can be shown as formula (1):
[0113] FunctionID=bytes4(hash(′function(a1,b1)′)) Formula (1)
[0114] Each method (function) can be composed of a method name and a parameter type. For example, function as shown in formula (1) can refer to the method name of a method (function). a1 and b1 can be used to represent the parameter type indicated by the method (such as uint256 type, address type, int type, etc.); hash() can be used to represent a hash function; byte4() can be used to represent a byte conversion function (specifically, it can be converted into a 4-byte byte array, for example, the first 4 bits of the hash result can be taken). Based on formula (1), it can be seen that the method identifier of a method calculated by method calculation can be a 4-byte byte array.
[0115] Further, for ease of understanding, the following will take the SolidityHelloWorld interface as an example to illustrate the specific method of calculating the interface identifier of the SolidityHelloWorld interface. The specific content included in the SolidityHelloWorld interface can be shown in Table 2:
[0116] Table 2
[0117]
[0118] Among them, the SolidityHelloWorld interface shown in Table 2 contains two methods, specifically the hello method and the world method. As shown in Table 2, external may mean that the hello method or the world method can be called externally (that is, when the smart contract implements the SolidityHelloWorld interface, the external system or other smart contracts can call the hello method or the world method in the SolidityHelloWorld interface); pure as shown in Table 2 is used to indicate that the hello method or the world method is readable. It should be understood that for the hello method, the parameter types indicated are uint256 and address, so the method identifier corresponding to the hello method can be calculated through the above formula (1) (the method identifier can be a 4-byte byte array, which can be recorded as hello.selector); similarly, for the world method, the parameter type indicated is int type, so the method identifier corresponding to the world method can also be calculated through the above formula (1) (the method identifier is also a 4-byte byte array, which can be recorded as world.selector); then, the two byte arrays (hello.selector and world.selector) can be XORed, thereby calculating a 4-byte byte array, which can be used as the interface identifier of the SolidityHelloWorld interface.
[0119] It should be noted that the specific content of the SolidityHelloWorld interface shown in Table 2 provided in the embodiment of the present application is an example provided for ease of understanding. It does not limit the SolidityHelloWorld interface to include a hello method or a world method, nor does it limit the parameter type indicated by the hello method or the world method. It has no practical reference significance.
[0120] In the embodiment of the present application, the first smart contract can realize the designated detection interface so that when the second smart contract calls a specific interface (such as the interface to be detected) in the first smart contract, it can first detect the interface to be detected through the interface detection function in the designated detection interface realized by the first smart contract to detect whether the first smart contract has realized the interface to be detected. After clarifying that the first smart contract has realized the interface to be detected, the second smart contract can call the interface to be detected realized by the first smart contract to interact with the first smart contract for data. This can reduce the situation where the first smart contract cannot execute or incorrectly executes logic after the second smart contract calls a certain interface in the first smart contract, thereby improving the reliability of the interaction between the first smart contract and the second smart contract, and at the same time, it can also improve the interoperability and scalability of smart contracts and promote the development of blockchain.
[0121] For further information, see Figure 3 , Figure 3 The present invention provides a flow chart of detecting the interface attributes of the interface to be detected by using an interface detection function. The flow chart is a flow chart illustrating the function logic indicated by the interface detection function as the first function logic. The flow chart may correspond to the above Figure 2 In the corresponding embodiment, for the function logic indicated by the interface detection function, a logical operation is performed on the interface identifier of the interface to be detected to obtain the process of the first smart contract for the interface attribute of the interface to be detected. Figure 3 As shown, the process may include at least the following steps S301 to S303:
[0122] Step S301: Obtain a support interface set corresponding to a first smart contract through a first function logic; the interface attributes of each support interface in the support interface set of the first smart contract are all interface support attributes.
[0123] Specifically, according to the steps indicated by the first function logic, the support interface set corresponding to the first smart contract can be obtained preferentially, wherein the support interface set here can refer to a set of interfaces supported by the first smart contract. The interface supported by the first smart contract can be called a support interface. Since each support interface in the support interface set is an interface supported by the first smart contract, then for each support interface in the support interface set, the interface attributes of the first smart contract to it are all interface support attributes.
[0124] Step S302, obtaining a supported interface identifier set corresponding to the supported interface set; a supported interface identifier in the supported interface identifier set refers to an interface identifier of a supported interface in the supported interface set.
[0125] Specifically, after obtaining the supported interface set of the first smart contract, the interface identifier of each supported interface in the supported interface set can be obtained. The interface identifier of each supported interface can be called a supported interface identifier, thereby obtaining a supported interface identifier set.
[0126] Step S303: traverse the supported interface identifier set based on the interface identifier of the interface to be detected to obtain a traversal result, and determine the interface attribute of the first smart contract for the interface to be detected according to the traversal result.
[0127] Specifically, according to the first function logic, the supported interface identifier set can be traversed based on the interface identifier of the interface to be detected to obtain a traversal result, and the interface attribute of the first smart contract for the interface to be detected can be determined according to the traversal result. The specific implementation method can be: if the traversal result indicates that there is a supported interface identifier that is the same as the interface identifier of the interface to be detected in the supported interface identifier set, then it can be determined that the interface attribute of the first smart contract for the interface to be detected is an interface supported attribute; and if the traversal result indicates that there is no supported interface identifier that is the same as the interface identifier of the interface to be detected in the supported interface identifier set, then it can be determined that the interface attribute of the first smart contract for the interface to be detected is an interface unsupported attribute.
[0128] It can be understood that the first function logic may refer to traversing and calculating the interface identifiers of all interfaces implemented by the first smart contract (that is, traversing the set of supported interface identifiers), and whether the interface identifier of the interface to be detected passed in can be equal to one of the supported interface identifiers. If there is a supported interface identifier that is equal to the interface identifier of the interface to be detected, then the comparison of the remaining supported interface identifiers can be stopped, and an operation result value (such as True) is obtained to characterize that the first smart contract supports the interface to be detected. That is to say, when there is a supported interface identifier that is equal to the interface identifier of the interface to be detected, it can be determined that the interface attribute of the first smart contract for the interface to be detected is the interface support attribute (that is, the first smart contract supports the interface to be detected); if all supported interface identifiers are traversed and no supported interface identifier is equal to the interface identifier of the interface to be detected, then it can be determined that the interface attribute of the first smart contract for the interface to be detected is the interface unsupported attribute (that is, the first smart contract does not support the interface to be detected).
[0129] In the embodiment of the present application, the first smart contract can realize the designated detection interface so that when the second smart contract calls a specific interface (such as the interface to be detected) in the first smart contract, it can first detect the interface to be detected through the interface detection function in the designated detection interface realized by the first smart contract to detect whether the first smart contract has realized the interface to be detected. After clarifying that the first smart contract has realized the interface to be detected, the second smart contract can call the interface to be detected realized by the first smart contract to interact with the first smart contract for data. This can reduce the situation where the first smart contract cannot execute or incorrectly executes logic after the second smart contract calls a certain interface in the first smart contract, thereby improving the reliability of the interaction between the first smart contract and the second smart contract.
[0130] For further information, see Figure 4 , Figure 4 This is another flow diagram of detecting the interface attributes of the interface to be detected by using the interface detection function provided by the embodiment of the present application. Among them, this flow is a flow diagram for illustrating the function logic indicated by the interface detection function as the second function logic as an example, and this flow can correspond to the above Figure 2 In the corresponding embodiment, for the function logic indicated by the interface detection function, a logical operation is performed on the interface identifier of the interface to be detected to obtain the process of the first smart contract for the interface attribute of the interface to be detected. Figure 4 As shown, the process may include at least the following steps S401-S402:
[0131] Step S401, through the second function logic, obtain the interface mapping table corresponding to the first smart contract; the interface mapping table contains the mapping relationship between the stored interface set and the interface attribute value set; there is a mapping relationship between an stored interface in the stored interface set and an interface attribute value in the interface attribute value set; the stored interface set contains the interface to be detected.
[0132] Specifically, according to the steps indicated by the second function logic, the interface mapping table corresponding to the first smart contract can be obtained first. The interface mapping table can refer to a table used to maintain the mapping relationship between different interfaces and different interface attribute values. The interfaces stored in the interface mapping table can include interfaces supported by the first smart contract, and can also include interfaces not supported by the first smart contract. The interface attribute value is used to reflect whether the first smart contract supports the interface. Then, through the interface mapping table, it can be determined whether the first smart contract supports the interface to be detected. In other words, the set of stored interfaces contained in the interface mapping table can include interfaces not supported by the first smart contract, and can also include interfaces supported by the first smart contract.
[0133] Step S402: Obtain the interface attribute value corresponding to the interface to be detected from the interface attribute value set, analyze the interface attribute value corresponding to the interface to be detected, and determine the interface attribute of the first smart contract for the interface to be detected.
[0134] Specifically, according to the second function logic, the interface attribute value corresponding to the interface to be detected can be obtained from the interface attribute value set, and the interface attribute value corresponding to the interface to be detected can be analyzed, thereby determining the interface attribute of the first smart contract for the interface to be detected. The specific implementation method can be: the interface attribute value corresponding to the interface to be detected can be analyzed to obtain the analysis result; if the analysis result indicates that the interface attribute value corresponding to the interface to be detected is the attribute value corresponding to the interface support attribute, then the interface attribute of the first smart contract for the interface to be detected can be determined to be the interface support attribute; and if the analysis result indicates that the interface attribute value corresponding to the interface to be detected is the attribute value corresponding to the interface unsupported attribute, then the interface attribute of the first smart contract for the interface to be detected can be determined to be the interface unsupported attribute.
[0135] It can be understood that the second function logic can mean that the first smart contract can maintain an interface mapping table of different interfaces and interface attribute values (used to reflect the interface attributes of the smart contract for the interface). In the interface mapping table, the interface identifiers of different interfaces can be used as keys, and the interface attribute values corresponding to the interfaces can be used as values. Then, for the interface identifier of the interface to be detected, it can be used as a key to obtain the corresponding value (the value with a mapping relationship) in the interface mapping table. If the value is the interface attribute value reflecting that the first smart contract supports the interface to be detected (such as True), then the interface detection function can obtain an operation result value (such as True) used to characterize that the first smart contract supports the interface to be detected; and if the value is the interface attribute value reflecting that the first smart contract does not support the interface to be detected (such as False), then the interface detection function can obtain an operation result value (such as False) used to characterize that the first smart contract does not support the interface to be detected. That is to say, the interface mapping table maintains the mapping relationship between different interfaces and interface attribute values. An interface attribute value is used to reflect the interface attribute of the first smart contract for the corresponding interface (that is, to reflect whether the first smart contract supports the corresponding interface). Then, for the interface identifier of the interface to be detected, the corresponding interface attribute value can be found in the interface mapping table, and the interface attribute value of the first smart contract for the interface to be detected can be determined.
[0136] In the embodiment of the present application, the first smart contract can realize the designated detection interface so that when the second smart contract calls a specific interface (such as the interface to be detected) in the first smart contract, it can first detect the interface to be detected through the interface detection function in the designated detection interface realized by the first smart contract to detect whether the first smart contract has realized the interface to be detected. After clarifying that the first smart contract has realized the interface to be detected, the second smart contract can call the interface to be detected realized by the first smart contract to interact with the first smart contract for data. This can reduce the situation where the first smart contract cannot execute or incorrectly executes logic after the second smart contract calls a certain interface in the first smart contract, thereby improving the reliability of the interaction between the first smart contract and the second smart contract.
[0137] For further information, see Figure 5 , Figure 5 : is a schematic diagram of the structure of a blockchain-based data processing device provided in an embodiment of the present application. The blockchain-based data processing device may be a computer program (including program code) running in a computer device, for example, the blockchain-based data processing device is an application software; the blockchain-based data processing device may be used to execute Figure 2 As shown in the method. Figure 5 As shown, the blockchain-based data processing device 1 may include: a request receiving module 11, a logic operation module 12 and an attribute returning module 13.
[0138] The request receiving module 11 is used to receive the interface detection request sent by the second smart contract; the first smart contract supports the specified detection interface, and the specified detection interface includes the interface detection function; the interface detection request includes the interface identifier of the interface to be detected;
[0139] A logic operation module 12, configured to perform a logic operation on the interface identifier of the interface to be detected through the function logic indicated by the interface detection function, and obtain the interface attribute of the first smart contract for the interface to be detected;
[0140] The attribute returning module 13 is used to return the interface attribute of the first smart contract for the interface to be detected to the second smart contract, so that the second smart contract can exchange data with the first smart contract through the interface to be detected.
[0141] The specific implementation of the request receiving module 11, the logic operation module 12 and the attribute returning module 13 can be found in the above Figure 2 The description of step S101 to step S103 in the corresponding embodiment will not be repeated here.
[0142] In one embodiment, the blockchain-based data processing device may further include: a receiving module 14, a trial execution module 15, and an execution result returning module 16.
[0143] The receiving module 14 is used to receive a function trial execution request sent by the second smart contract; the function trial execution request is used to request the first smart contract to try to execute the interface detection function contained in the specified detection interface, and the function trial execution request includes the interface identifier of the specified detection interface;
[0144] A trial execution module 15 is used to perform a trial execution on the interface detection function based on the interface identifier of the specified detection interface to obtain a trial execution result;
[0145] The execution result returning module 16 is used to return the trial execution result to the second smart contract, so that the second smart contract can detect and process the interface properties of the first smart contract for the specified detection interface based on the trial execution result.
[0146] The specific implementation of the receiving module 14, the trial execution module 15 and the execution result returning module 16 can be found in the above Figure 2 The description of step S101 in the corresponding embodiment will not be repeated here.
[0147] In one embodiment, the trial execution result is a trial execution success result;
[0148] The blockchain-based data processing device 1 may further include: a call request receiving module 17 , a parameter calculation module 18 , and a calculation result returning module 19 .
[0149] A call request receiving module 17 is used to receive a first function call request sent by the second smart contract based on a successful trial execution result; the first function call request is used to request the first smart contract to call an interface detection function, and the first function call request includes a specific detection parameter for detecting a specified detection interface;
[0150] The parameter operation module 18 is used to perform a logic operation on a specific detection parameter through the function logic indicated by the interface detection function to obtain a logic operation result corresponding to the specific detection parameter;
[0151] The operation result returning module 19 is used to return the logic operation result to the second smart contract, so that when the second smart contract determines that the logic operation result is a specific operation result corresponding to the specific detection parameter, it determines that the interface attribute of the first smart contract for the specified detection interface is an interface support attribute.
[0152] The specific implementation of the call request receiving module 17, the parameter calculation module 18 and the calculation result returning module 19 can be found in the above Figure 2The description of step S101 in the corresponding embodiment will not be repeated here.
[0153] In one embodiment, after the interface properties of the interface to be detected by the first smart contract are returned to the second smart contract, the second smart contract is used to analyze the interface properties of the interface to be detected, and when it is determined that the interface properties of the interface to be detected are interface support properties, data is interacted with the first smart contract through the interface to be detected.
[0154] In one embodiment, the function logic indicated by the interface detection function is a first function logic;
[0155] The logic operation module 12 performs a logic operation on the interface identifier of the interface to be detected through the function logic indicated by the interface detection function, and obtains a specific implementation method of the first smart contract for the interface attribute of the interface to be detected, including:
[0156] Obtain a support interface set corresponding to the first smart contract through the first function logic; the interface attributes of each support interface in the support interface set of the first smart contract are all interface support attributes;
[0157] Get the supported interface identifier set corresponding to the supported interface set; a supported interface identifier in the supported interface identifier set refers to an interface identifier of a supported interface in the supported interface set;
[0158] Based on the interface identifier of the interface to be detected, the supported interface identifier set is traversed to obtain a traversal result, and the interface attribute of the first smart contract for the interface to be detected is determined according to the traversal result.
[0159] In one embodiment, the logic operation module 12 determines the specific implementation method of the interface attribute of the first smart contract for the interface to be detected according to the traversal result, including:
[0160] If the traversal result indicates that there is a supported interface identifier that is the same as the interface identifier of the interface to be detected in the supported interface identifier set, then the interface attribute of the first smart contract for the interface to be detected is determined to be an interface support attribute;
[0161] If the traversal result indicates that there is no supported interface identifier that is the same as the interface identifier of the interface to be detected in the supported interface identifier set, it is determined that the interface attribute of the first smart contract for the interface to be detected is an interface unsupported attribute.
[0162] In one embodiment, the function logic indicated by the interface detection function is a second function logic;
[0163] The logic operation module 12 performs a logic operation on the interface identifier of the interface to be detected through the function logic indicated by the interface detection function, and obtains a specific implementation method of the first smart contract for the interface attribute of the interface to be detected, including:
[0164] Through the second function logic, an interface mapping table corresponding to the first smart contract is obtained; the interface mapping table includes a mapping relationship between an existing interface set and an interface attribute value set; there is a mapping relationship between an existing interface in the existing interface set and an interface attribute value in the interface attribute value set; the existing interface set includes an interface to be detected;
[0165] In the interface attribute value set, the interface attribute value corresponding to the interface to be detected is obtained, the interface attribute value corresponding to the interface to be detected is analyzed, and the interface attribute of the first smart contract for the interface to be detected is determined.
[0166] In one embodiment, the logic operation module 12 analyzes the interface attribute value corresponding to the interface to be detected, and determines the specific implementation method of the first smart contract for the interface attribute of the interface to be detected, including:
[0167] Analyze the interface attribute value corresponding to the interface to be detected to obtain the analysis result;
[0168] If the analysis result indicates that the interface attribute value corresponding to the interface to be detected is the attribute value corresponding to the interface support attribute, then it is determined that the interface attribute of the first smart contract for the interface to be detected is the interface support attribute;
[0169] If the analysis result indicates that the interface attribute value corresponding to the interface to be detected is the attribute value corresponding to the interface not supported attribute, it is determined that the interface attribute of the first smart contract for the interface to be detected is the interface not supported attribute.
[0170] In one embodiment, before the logic operation module 12 performs a logical operation on the interface identifier of the interface to be detected through the function logic indicated by the interface detection function to obtain the interface attributes of the first smart contract for the interface to be detected, the blockchain-based data processing device 1 may also include: an interface set acquisition module 20, a quantity statistics module 21, a quantity analysis module 22 and a logic determination module 23.
[0171] The interface set acquisition module 20 is used to acquire the support interface set corresponding to the first smart contract; the interface attributes of each support interface in the support interface set of the first smart contract are all interface support attributes;
[0172] A quantity statistics module 21, used to count the number of interfaces of the supported interfaces included in the supported interface set;
[0173] A quantity analysis module 22, configured to perform a quantity analysis on the number of interfaces based on a quantity threshold;
[0174] The logic determination module 23 is used to determine the function logic indicated by the interface detection function in the configuration function logic set corresponding to the interface detection function based on the quantity analysis result.
[0175] The specific implementation of the interface set acquisition module 20, the quantity statistics module 21, the quantity analysis module 22 and the logic determination module 23 can be found in the above Figure 2 The description of step S102 in the corresponding embodiment will not be repeated here.
[0176] In one embodiment, the logic determination module 23 determines the specific implementation of the function logic indicated by the interface detection function in the configuration function logic set corresponding to the interface detection function based on the quantity analysis result, including:
[0177] If the quantity analysis result is a first quantity analysis result indicating that the number of interfaces is greater than the quantity threshold, obtaining a first function logic indicated by the first quantity analysis result in the configuration function logic set, and determining the first function logic as the function logic indicated by the interface detection function;
[0178] If the quantity analysis result is a second quantity analysis result indicating that the number of interfaces is greater than the quantity threshold, in the configuration function logic set, a second function logic indicated by the second quantity analysis result is obtained, and the second function logic is determined as the function logic indicated by the interface detection function.
[0179] In one embodiment, the interface attribute of the first smart contract for the interface to be detected is an interface support attribute;
[0180] After the attribute return module 13 returns the interface attributes of the first smart contract for the interface to be detected to the second smart contract, the blockchain-based data processing device 1 may further include: a function request receiving module 24, an operation module 25 and a parameter result returning module 26.
[0181] The function request receiving module 24 is used to receive a second function call request for a target function sent by a second smart contract; the target function is a function included in the interface to be detected, and the second function call request for the target function includes an interaction parameter;
[0182] The operation module 25 is used to execute the target function logic indicated by the target function based on the second function call request, perform parameter operation on the interaction parameter through the target function logic, and obtain the parameter operation result corresponding to the interaction parameter;
[0183] The parameter result returning module 26 is used to return the parameter operation result to the second smart contract.
[0184] The specific implementation of the function request receiving module 24, the operation module 25 and the parameter result returning module 26 can be found in the above Figure 2 The description of step S103 in the corresponding embodiment will not be repeated here.
[0185] In an embodiment of the present application, the first smart contract can realize a designated detection interface so that when the second smart contract calls a specific interface (such as the interface to be detected) in the first smart contract, it first detects the interface to be detected through the interface detection function in the designated detection interface implemented by the first smart contract to detect whether the first smart contract has implemented the interface to be detected. After clarifying that the first smart contract has implemented the interface to be detected, the second smart contract can call the interface to be detected implemented by the first smart contract to interact with the first smart contract. This can reduce the situation where the first smart contract cannot execute or incorrectly executes logic after the second smart contract calls a certain interface in the first smart contract, thereby improving the reliability of the interaction between the first smart contract and the second smart contract. In summary, the present application can accurately detect the interfaces supported by smart contracts, thereby improving the reliability of the interactive services of smart contracts.
[0186] For further information, see Figure 6 , Figure 6 Schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 6 As shown, the above-mentioned computer device 8000 may include: a processor 8001, a network interface 8004 and a memory 8005. In addition, the above-mentioned computer device 8000 also includes: a user interface 8003, and at least one communication bus 8002. Among them, the communication bus 8002 is used to realize the connection and communication between these components. Among them, the user interface 8003 may include a display screen (Display), a keyboard (Keyboard), and the optional user interface 8003 may also include a standard wired interface and a wireless interface. The network interface 8004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 8005 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 8005 may optionally also be at least one storage device located away from the aforementioned processor 8001. As Figure 6 As shown, the memory 8005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application.
[0187] exist Figure 6In the computer device 8000 shown, the network interface 8004 can provide a network communication function; the user interface 8003 is mainly used to provide an input interface for the user; and the processor 8001 can be used to call the device control application stored in the memory 8005 to achieve:
[0188] Receive an interface detection request sent by the second smart contract; the first smart contract supports a specified detection interface, and the specified detection interface includes an interface detection function; the interface detection request includes an interface identifier of the interface to be detected;
[0189] Through the function logic indicated by the interface detection function, a logical operation is performed on the interface identifier of the interface to be detected to obtain the interface attribute of the first smart contract for the interface to be detected;
[0190] The interface properties of the first smart contract for the interface to be detected are returned to the second smart contract, so that the second smart contract can interact with the first smart contract through the interface to be detected.
[0191] It should be understood that the computer device 8000 described in the embodiment of the present application can execute the above Figure 2 The description of the data processing method based on blockchain in the corresponding embodiment can also be performed as described above. Figure 6 The description of the blockchain-based data processing device 1 in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of using the same method will not be repeated here.
[0192] In addition, it should be pointed out here that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the data processing computer device 8000 mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, the computer program can execute the above-mentioned data processing computer device 8000. Figure 2 The description of the above-mentioned blockchain-based data processing method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application.
[0193] The computer-readable storage medium may be a data processing device based on blockchain provided in any of the aforementioned embodiments or an internal storage unit of the computer device, such as a hard disk or memory of a computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (smart media card, SMC), a secure digital (secure digital, SD) card, a flash card (flash card), etc. equipped on the computer device. Furthermore, the computer-readable storage medium may also include both an internal storage unit of the computer device and an external storage device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
[0194] In one aspect of the present application, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the method provided in one aspect of the embodiments of the present application.
[0195] The terms "first", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the term "comprising" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment that includes a series of steps or units is not limited to the listed steps or modules, but optionally includes steps or modules that are not listed, or optionally includes other step units inherent to these processes, methods, devices, products, or equipment.
[0196] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0197] The method and related apparatus provided by the embodiment of the present application are described with reference to the method flow chart and / or structural diagram provided by the embodiment of the present application. Specifically, each process and / or box in the method flow chart and / or structural diagram, as well as the combination of the processes and / or boxes in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the process. Figure 1 Schematic diagram of one or more processes and / or structures Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 Schematic diagram of one or more processes and / or structures Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A flow or multiple flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.
[0198] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A data processing method based on blockchain, characterized in that: include: The first smart contract receives an interface detection request sent by the second smart contract; The first smart contract supports a specified detection interface, wherein the specified detection interface includes an interface detection function; the interface detection request includes an interface identifier of an interface to be detected; Performing a logical operation on the interface identifier of the interface to be detected through the function logic indicated by the interface detection function to obtain the interface attribute of the first smart contract for the interface to be detected; The interface attribute of the first smart contract for the interface to be detected is returned to the second smart contract, so that the second smart contract interacts with the first smart contract through the interface to be detected.
2. The method according to claim 1, characterized in that The method further comprises: The first smart contract receives a function trial execution request sent by the second smart contract; the function trial execution request is used to request the first smart contract to try to execute the interface detection function contained in the specified detection interface, and the function trial execution request includes an interface identifier of the specified detection interface; Based on the interface identifier of the specified detection interface, the interface detection function is tested to obtain a test execution result; The trial execution result is returned to the second smart contract, so that the second smart contract performs detection processing on the interface properties of the first smart contract for the specified detection interface based on the trial execution result.
3. The method according to claim 2, characterized in that The trial execution result is a successful trial execution result; The method further comprises: receiving a first function call request sent by the second smart contract based on the successful trial execution result; the first function call request is used to request the first smart contract to call the interface detection function, and the first function call request includes a specific detection parameter for detecting the specified detection interface; Performing a logical operation on the specific detection parameter through the function logic indicated by the interface detection function to obtain a logical operation result corresponding to the specific detection parameter; The logic operation result is returned to the second smart contract, so that when the second smart contract determines that the logic operation result is the specific operation result corresponding to the specific detection parameter, it determines that the interface attribute of the first smart contract for the specified detection interface is an interface support attribute.
4. The method according to claim 1, characterized in that: After returning the interface attributes of the interface to be detected by the first smart contract to the second smart contract, the second smart contract is used to analyze the interface attributes of the interface to be detected, and when it is determined that the interface attributes of the interface to be detected are interface support attributes, data is exchanged with the first smart contract through the interface to be detected.
5. The method according to claim 1, characterized in that The function logic indicated by the interface detection function is the first function logic; The function logic indicated by the interface detection function performs a logical operation on the interface identifier of the interface to be detected to obtain the interface attribute of the first smart contract for the interface to be detected, including: Obtaining, through the first function logic, a set of supported interfaces corresponding to the first smart contract; the interface attributes of each supported interface in the set of supported interfaces of the first smart contract are all interface support attributes; Acquire a supported interface identifier set corresponding to the supported interface set; a supported interface identifier in the supported interface identifier set refers to an interface identifier of a supported interface in the supported interface set; The supported interface identifier set is traversed based on the interface identifier of the interface to be detected to obtain a traversal result, and the interface attribute of the first smart contract for the interface to be detected is determined according to the traversal result.
6. The method according to claim 5, characterized in that The determining, according to the traversal result, the interface attribute of the first smart contract for the interface to be detected includes: If the traversal result indicates that there is a supported interface identifier that is the same as the interface identifier of the interface to be detected in the supported interface identifier set, determining that the interface attribute of the first smart contract for the interface to be detected is an interface support attribute; If the traversal result indicates that there is no supported interface identifier that is the same as the interface identifier of the interface to be detected in the supported interface identifier set, it is determined that the interface attribute of the first smart contract for the interface to be detected is an interface unsupported attribute.
7. The method according to claim 1, characterized in that The function logic indicated by the interface detection function is the second function logic; The function logic indicated by the interface detection function performs a logical operation on the interface identifier of the interface to be detected to obtain the interface attribute of the first smart contract for the interface to be detected, including: Obtain an interface mapping table corresponding to the first smart contract through the second function logic; the interface mapping table includes a mapping relationship between an existing interface set and an interface attribute value set; a mapping relationship exists between an existing interface in the existing interface set and an interface attribute value in the interface attribute value set; the existing interface set includes the interface to be detected; In the interface attribute value set, the interface attribute value corresponding to the interface to be detected is obtained, the interface attribute value corresponding to the interface to be detected is analyzed, and the interface attribute of the first smart contract for the interface to be detected is determined.
8. The method according to claim 7, characterized in that The analyzing the interface attribute value corresponding to the interface to be detected to determine the interface attribute of the first smart contract for the interface to be detected includes: Analyze the interface attribute value corresponding to the interface to be detected to obtain an analysis result; If the analysis result indicates that the interface attribute value corresponding to the interface to be detected is the attribute value corresponding to the interface support attribute, it is determined that the interface attribute of the first smart contract for the interface to be detected is the interface support attribute; If the analysis result indicates that the interface attribute value corresponding to the interface to be detected is the attribute value corresponding to the interface not supported attribute, it is determined that the interface attribute of the first smart contract for the interface to be detected is the interface not supported attribute.
9. The method according to claim 1, characterized in that: Before performing a logical operation on the interface identifier of the interface to be detected by the function logic indicated by the interface detection function to obtain the interface attribute of the first smart contract for the interface to be detected, the method further includes: Obtain a set of supported interfaces corresponding to the first smart contract; the interface attributes of each supported interface in the set of supported interfaces of the first smart contract are all interface support attributes; Count the number of supported interfaces included in the supported interface set, perform a quantity analysis on the number of interfaces based on a quantity threshold, and determine the function logic indicated by the interface detection function in the configuration function logic set corresponding to the interface detection function based on the quantity analysis result.
10. The method according to claim 9, characterized in that The determining, based on the quantity analysis result, in the configuration function logic set corresponding to the interface detection function, the function logic indicated by the interface detection function includes: If the quantity analysis result is a first quantity analysis result indicating that the number of interfaces is greater than the quantity threshold, obtaining a first function logic indicated by the first quantity analysis result in the configuration function logic set, and determining the first function logic as the function logic indicated by the interface detection function; If the quantity analysis result is a second quantity analysis result indicating that the number of interfaces is greater than the quantity threshold, then in the configuration function logic set, obtain the second function logic indicated by the second quantity analysis result, and determine the second function logic as the function logic indicated by the interface detection function.
11. The method according to claim 1, characterized in that: The interface attribute of the first smart contract for the interface to be detected is an interface support attribute; After returning the interface attribute of the first smart contract for the interface to be detected to the second smart contract, the method further includes: receiving a second function call request for a target function sent by the second smart contract; the target function is a function included in the interface to be detected, and the second function call request for the target function includes an interaction parameter; Executing the target function logic indicated by the target function based on the second function call request, performing parameter operation on the interaction parameter through the target function logic, and obtaining the parameter operation result corresponding to the interaction parameter; Return the parameter operation result to the second smart contract.
12. A data processing device based on blockchain, characterized in that: include: A request receiving module, used to receive an interface detection request sent by a second smart contract; The first smart contract supports a specified detection interface, wherein the specified detection interface includes an interface detection function; the interface detection request includes an interface identifier of an interface to be detected; A logic operation module, used to perform a logic operation on the interface identifier of the interface to be detected through the function logic indicated by the interface detection function, so as to obtain the interface attribute of the first smart contract for the interface to be detected; The attribute returning module is used to return the interface attribute of the first smart contract for the interface to be detected to the second smart contract, so that the second smart contract can exchange data with the first smart contract through the interface to be detected.
13. A computer device, characterized in that: include: Processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide a network communication function, the memory is used to store a computer program, and the processor is used to call the computer program so that the computer device executes the method described in any one of claims 1-11.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the method according to any one of claims 1 to 11.
15. A computer program product, characterized in that The computer program product comprises a computer program, which is stored in a computer-readable storage medium. The computer program is suitable for being read and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 11.
