A blockchain smart contract data processing method and device
By introducing data factory contracts and data proxy contracts into the blockchain, the data storage structure of smart contracts is optimized, which solves the query failure problem caused by storing large amounts of data in a single smart contract, achieves efficient data reading and writing, and reduces system upgrade costs.
Patent Information
- Application Number
- CN202310034333.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-10
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2043-01-10
AI Technical Summary
In a scenario where business and data are separated, when a single smart contract stores a large amount of data, data query fails. In addition, the cost of optimizing and upgrading the data storage structure of the blockchain system is high. How to make it compatible with the reading and writing methods of historical data and improve data query efficiency?
The data contract is used as the database, and the data factory contract and data proxy contract are introduced. The data proxy contract is used to realize the reading and writing method compatible with historical data, and the data proxy contract is saved in the form of a linked list to optimize the data storage structure.
It improves the reading and writing efficiency of smart contract data, reduces the engineering deployment cost of the blockchain system, and adapts to the storage needs of large data without destroying the decentralized characteristics.
Smart Images

Figure CN116166747B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer software technology, and in particular to a blockchain smart contract data processing method, device, electronic device, and storage medium. Background Art
[0002] Blockchain smart contracts enable operations such as adding, modifying, querying, and deleting data. However, when a single smart contract stores large amounts of data, the characteristics of different chains and virtual machines can result in large data storage volumes, leading to contract data query failures. Especially when business and data are separated, with independent data processing smart contracts serving as databases, finding ways to maintain compatibility with existing data read and write methods, optimize the smart contract data storage structure, and improve data query efficiency are pressing technical challenges. Summary of the Invention
[0003] The purpose of the embodiments of this specification is to address the above-mentioned problems and provide a blockchain smart contract data processing method, device, electronic device and storage medium.
[0004] To solve the above technical problems, the embodiments of this specification are implemented as follows:
[0005] In a first aspect, a blockchain smart contract data processing method is proposed, which deploys an application contract, a data contract, and a data factory contract in a blockchain; wherein the application contract is used to issue transaction data processing instructions, the data contract is used to define the relevant interface for transaction data processing, and the data factory contract is used to manage a data proxy contract, and the data proxy contract corresponds to the data contract and implements the interface of the data contract; the method includes:
[0006] The data factory contract creates and deploys a first data proxy contract to the blockchain, and updates the current data proxy contract address of the data factory contract to the first data proxy contract address;
[0007] The application contract calls the data factory contract to obtain the address of the first data proxy contract, so that the application contract instructs the first data proxy contract to perform transaction data processing operations, where the transaction data processing operations include at least adding, modifying, and querying;
[0008] Determine whether a new data proxy contract needs to be deployed based on preset rules;
[0009] When a new data proxy contract needs to be deployed, the data factory contract creates and deploys a second data proxy contract to the blockchain, and updates the current data proxy contract address of the data factory contract with the second data proxy contract address. The second data proxy contract records the first data proxy contract address.
[0010] Furthermore, after the data factory contract creates and deploys the first data proxy contract to the blockchain, the application contract writes the first data contract address into the first data proxy contract.
[0011] Furthermore, the process of the application contract calling the data factory contract to obtain the address of the first data proxy contract so that the application contract instructs the first data proxy contract to perform the transaction data processing operation includes:
[0012] The first data proxy contract executes the operation of adding and / or modifying transaction data;
[0013] Based on the execution results of the transaction data addition and / or modification operations, the data factory contract updates the data storage capacity of the first data contract.
[0014] Furthermore, whether a new data proxy contract needs to be deployed is determined based on preset rules, including: the preset rules include when a preset periodic timer is triggered; and / or, the data storage capacity of the first data contract is greater than or equal to a storage capacity threshold.
[0015] Furthermore, when a new data proxy contract needs to be deployed, the process of creating and deploying a second data proxy contract to the blockchain by the data factory contract includes: creating the second data proxy contract based on the second data contract address and the first data proxy contract address.
[0016] Furthermore, the data factory contract is also used to uniformly receive instructions from the application contract; and also includes: when the application contract issues a transaction data query instruction, the data factory contract calls any data proxy contract to perform a transaction data query operation; when any data proxy contract fails to query the transaction data, it calls its previous data proxy contract to continue the query.
[0017] Furthermore, the data factory contract includes a Bloom filter and saves the Bloom vector value corresponding to each data contract; and when the application contract writes data to the data contract, the application contract updates the Bloom vector value of the corresponding data contract based on the key value of the data.
[0018] Furthermore, the process of querying transaction data based on the Bloom filter includes:
[0019] Obtain the key value of the data to be queried, and query the data to be queried in the latest data contract based on the key value;
[0020] If the corresponding data is not found in the latest data contract, the data factory contract will query the data to be queried in the corresponding data contract based on the bloom vector value corresponding to the key;
[0021] Feedback transaction data query operation results to the application contract.
[0022] In a second aspect, a blockchain smart contract data processing device is proposed, which deploys an application contract, a data contract, and a data factory contract in a blockchain; wherein the application contract is used to issue transaction data processing instructions, the data contract is used to define the relevant interface for transaction data processing, and the data factory contract is used to manage a data proxy contract, which corresponds to the data contract and implements the interface of the data contract; the device includes:
[0023] A first module is configured to create and deploy a first data proxy contract to the blockchain from the data factory contract, and to update the current data proxy contract address of the data factory contract to the first data proxy contract address;
[0024] The second module is configured to enable the application contract to call the data factory contract to obtain the address of the first data proxy contract, so that the application contract instructs the first data proxy contract to perform transaction data processing operations, wherein the transaction data processing operations include at least adding, modifying, and querying;
[0025] The third module can determine whether a new data proxy contract needs to be deployed based on preset rules;
[0026] The fourth module can create and deploy a second data proxy contract to the blockchain by the data factory contract when a new data proxy contract needs to be deployed, and update the current data proxy contract address of the data factory contract to the second data proxy contract address, and the second data proxy contract records the first data proxy contract address.
[0027] Furthermore, the data factory contract is further configured to uniformly receive instructions from the application contract; and further includes:
[0028] The fifth module enables the data factory contract to call any data proxy contract to perform a transaction data query operation when the application contract issues a transaction data query instruction; when any data proxy contract fails to query the transaction data, it calls its previous data proxy contract to continue the query.
[0029] Furthermore, the data factory contract includes a Bloom filter and saves the Bloom vector value corresponding to each data contract; and when the application contract writes data to the data contract, the application contract updates the Bloom vector value of the corresponding data contract based on the key value of the data.
[0030] Furthermore, the process of querying transaction data based on the Bloom filter includes:
[0031] Obtain the key value of the data to be queried, and query the data to be queried in the latest data contract based on the key value;
[0032] If the corresponding data is not found in the latest data contract, the data factory contract will query the data to be queried in the corresponding data contract based on the bloom vector value corresponding to the key;
[0033] Feedback transaction data query operation results to the application contract.
[0034] In a third aspect, an electronic device is proposed, comprising: a processor; and a memory arranged to store computer-executable instructions, wherein when the executable instructions are executed, the processor executes the blockchain smart contract data processing method described in the first aspect.
[0035] In a fourth aspect, a computer-readable storage medium is proposed, which stores one or more programs. When the one or more programs are executed by an electronic device including multiple applications, the electronic device executes the blockchain smart contract data processing method described in the first aspect.
[0036] This specification can achieve at least the following technical effects:
[0037] The embodiment of the present invention aims to separate business and data, adopts data contracts as databases, and adds data factory contracts and data proxy contracts between application contracts and data contracts. The data proxy contract implements a reading and writing method compatible with historical existing data, and saves the data proxy contract in the form of a linked list, realizing a chain storage contract structure that separates business and data, thereby improving the efficiency of reading and writing contract data. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0039] Figure 1 This is one of the schematic diagrams of the blockchain smart contract data processing method provided in the embodiments of this specification.
[0040] Figure 2This is the second schematic diagram of the blockchain smart contract data processing method provided in the embodiments of this specification.
[0041] Figure 3 This is the third schematic diagram of the blockchain smart contract data processing method provided in the embodiments of this specification.
[0042] Figure 4 This is the fourth schematic diagram of the blockchain smart contract data processing method provided in the embodiments of this specification.
[0043] Figure 5 This is one of the schematic diagrams of the blockchain smart contract data processing device provided in the embodiments of this specification.
[0044] Figure 6 This is the second schematic diagram of the blockchain smart contract data processing device provided in the embodiments of this specification.
[0045] Figure 7 A schematic diagram of the structure of an electronic device provided in one embodiment of this specification. DETAILED DESCRIPTION
[0046] To help those skilled in the art better understand the technical solutions in this specification, the following will provide a clear and complete description of the technical solutions in the embodiments of this specification, in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. All other embodiments derived by those skilled in the art based on the embodiments in this specification without creative effort shall fall within the scope of protection of this specification.
[0047] The following is a detailed description of a blockchain smart contract data processing solution involved in this specification through a specific example.
[0048] Key Terms
[0049] Smart Contracts: Technically, smart contracts are considered to be built on a blockchain, allowing the execution of specific contract programs. Since both the code and state of a smart contract are stored on the blockchain, any user with access to the blockchain can see the smart contract. Smart contracts are not dependent on a specific hardware device; their code is executed by all participating mining devices, which also means that the computing power required to access a single contract is limited. Smart contracts are assembled languages programmed on the blockchain. Typically, people don't write bytecode themselves, but compile it from a higher-level language, such as Solidity, a specialized language similar to JavaScript. Code execution is automatic, either successfully executing or undoing all state changes, preventing partial contract execution. Therefore, smart contracts can be described as computer programs running on a replicated, shared ledger, capable of processing information and receiving, storing, and sending value.
[0050] Data storage of smart contracts: The code of a smart contract is fixed and stored on an immutable blockchain. Once published, it cannot be changed. However, the smart contract may be called multiple times in the future, which may cause the data variables of the contract to be modified. First of all, there are two types of variables in the contract: memory and storage. Memory is a local memory variable, and the data is not stored after the contract ends. Storage is a persistent variable that needs to be stored. Secondly, the storage variable exists in the local file of the Ethereum full node. The underlying implementation solution is stateDB. The stateDB data will construct a compressed prefix Merkle tree and store the root of the tree in the block header. Thirdly, considering that it is expensive to store data resources in the block, most of the current decentralized applications DApp, such as various NFT tokens, store most of the business data in a centralized manner and some core data in a decentralized manner on the chain.
[0051] Smart Contracts and Data Storage: Smart contracts operating databases are a common application scenario. Storage is used to maintain smart contract state. Each contract uses its own Solidity storage. In Solidity, the primary commands for accessing storage data are SLOAD and STORE. Data in storage consists of multiple key-value pairs, consisting of a storage key and a storage value, where each key-value pair is a single word. In Solidity, different data types have corresponding rules for determining their structure, and Solidity defines the logical structure of storage keys. The same storage key may appear in different contracts, so storage cannot be directly stored in existing databases within its logical structure. To more effectively integrate with the chain, the physical storage on the chain must be designed accordingly. Since storage access in smart contracts typically only requires a portion of the storage key, it is best to load storage on demand rather than loading all storage into memory each time.
[0052] This invention addresses the issue of how to maintain compatibility with existing historical data read and write methods, optimize the smart contract data storage structure, and improve data query efficiency when business and data are separated and independent data processing smart contracts serve as databases. Blockchain smart contracts enable operations such as data addition, modification, query, and deletion. However, when a single smart contract stores large amounts of data, the characteristics of different chains and virtual machines can result in significant data storage requirements, leading to contract data query failures. Furthermore, since existing smart contract-based blockchain systems are operating in a stable state, any changes to their data storage structure would inevitably require business upgrades, increasing blockchain and smart contract project deployment costs. Furthermore, since smart contracts store data on the blockchain, including both historical data and data frequently used by current smart contracts, data applications, particularly storage strategies and query applications, require a separation of hot and cold data. Therefore, the smart contract data storage structure must adapt to these data application scenarios. Furthermore, given the limited computing power of a single smart contract, the technical features of this invention include overcoming these storage limitations and optimizing the smart contract call structure to accommodate large data storage needs without compromising the decentralized nature of blockchain.
[0053] Example 1
[0054] like Figure 1 The figure shows a schematic diagram of a blockchain smart contract data processing method according to an embodiment of the present invention. In the blockchain, an application contract App.sol, a data contract Data.sol, and a data factory contract DataFactory.sol are deployed; wherein the application contract App.sol is used to issue transaction data processing instructions, the data contract Data.sol is used to define the relevant interfaces for transaction data processing, and the data factory contract DataFactory.sol is used to manage the data proxy contract DataDelegation.sol. The data proxy contract DataDelegation.sol corresponds to the data contract Data.sol and implements the interface of the data contract Data.sol. Therefore, the method includes:
[0055] S1: The data factory contract creates and deploys a first data proxy contract to the blockchain, and updates the current data proxy contract address of the data factory contract to the first data proxy contract address.
[0056] Optionally, after the data factory contract creates and deploys the first data proxy contract to the blockchain, the application contract writes the first data contract address to the first data proxy contract. It should be noted that the first data contract and the first data proxy contract have a corresponding relationship. Since a single data contract Data.sol stores a large amount of data, the characteristics of different chains and virtual machines will result in a large amount of data storage, which in turn causes the contract data query to fail. Therefore, in one implementation of an embodiment of the present invention, the data contract Data.sol is divided into several sub-data contracts, each of which has a unique corresponding data proxy contract.
[0057] S2: The application contract calls the data factory contract to obtain the address of the first data proxy contract, so that the application contract instructs the first data proxy contract to perform transaction data processing operations, and the transaction data processing operations at least include adding, modifying and querying.
[0058] Alternatively, as Figure 2 As shown, the process of the application contract calling the data factory contract to obtain the address of the first data proxy contract so that the application contract instructs the first data proxy contract to perform the transaction data processing operation includes:
[0059] S21: The first data proxy contract executes the transaction data addition and / or modification operation;
[0060] S22: Based on the execution results of the transaction data addition and / or modification operations, the data factory contract updates the data storage capacity of the first data contract.
[0061] S3: Determine whether a new data proxy contract needs to be deployed based on preset rules.
[0062] Optionally, whether a new data proxy contract needs to be deployed is determined based on preset rules, and the preset rules include when a preset periodic timer is triggered, and / or the data storage volume of the first data contract is greater than or equal to a storage volume threshold. Specifically, after the data storage is completed, DataDelegation.sol determines whether a new DataDelegation.sol contract needs to be deployed based on the above rules. It should be noted that the determination of whether a new data proxy contract needs to be deployed can be made by either the data factory contract or the current data proxy contract.
[0063] Optionally, when a new data proxy contract needs to be deployed, the Data Factory contract creates and deploys a second data proxy contract to the blockchain, including: creating the second data proxy contract based on the second data contract address and the first data proxy contract address. Specifically, after deploying the new data contract Data.sol, a new DataDelegation.sol is constructed using the new data contract Data.sol address and the previous DataDelegation.sol address. The new DataDelegation.sol address is replaced in DataFactory.sol, thereby implementing the data storage linked list structure.
[0064] S4: When a new data proxy contract needs to be deployed, the data factory contract creates and deploys a second data proxy contract to the blockchain, and updates the current data proxy contract address of the data factory contract with the second data proxy contract address. The second data proxy contract records the first data proxy contract address.
[0065] Optionally, when a new data proxy contract needs to be deployed, the process of creating and deploying a second data proxy contract to the blockchain by the data factory contract includes: creating the second data proxy contract based on the data contract address and the first data proxy contract address.
[0066] like Figure 3 FIGURE 1 illustrates another implementation of the blockchain smart contract data processing method according to an embodiment of the present invention. The data factory contract is further configured to uniformly receive instructions from the application contract; and further includes:
[0067] S5: When the application contract issues a transaction data query instruction, the data factory contract calls any data proxy contract to perform a transaction data query operation; and when any data proxy contract fails to query the transaction data, it calls its previous data proxy contract to continue the query.
[0068] Optionally, the data factory contract includes a Bloom filter and saves the Bloom vector value corresponding to each data contract; and when the application contract writes data to the data contract, the application contract updates the Bloom vector value of the corresponding data contract based on the key value of the data.
[0069] Alternatively, as Figure 4 As shown in the figure, the process of querying transaction data based on Bloom filter includes:
[0070] S41: Obtain the key value of the data to be checked, and query the data to be checked in the latest data contract based on the key value;
[0071] S42: If the corresponding data is not found in the latest data contract, the data factory contract queries the corresponding data contract for the data to be queried based on the Bloom vector value corresponding to the key;
[0072] S43: Feedback the transaction data query operation result to the application contract.
[0073] Specifically, a Bloom filter is added to the reading and writing process, and the Bloom algorithm uses multiple hash values. First, the Bloom filter must be initialized, that is, the data factory contract stores different Bloom vectors corresponding to each data contract; when the application contract App.sol writes data to the data contract Data.sol, the application contract App.sol must update the Bloom vector value corresponding to the data contract Data.sol being written based on the key value key of the written transaction data. This Bloom vector value can return the corresponding transaction data corresponding to the key value key when obtaining the input key value key. The reason is that the corresponding transaction data corresponding to the key value key is likely to be stored in the data contract corresponding to the Bloom vector value that matches the key value key. When performing a specific query operation based on the Bloom filter, it is first assumed that the data to be queried is stored in the latest data contract, and the key value key is directly used to query the corresponding transaction data in the latest data contract; if found, continue with the subsequent steps. If not found, the data factory contract searches for the data contract corresponding to the key value key based on the Bloom vector value corresponding to the key value key and performs a query. Because the Bloom algorithm is optimistic and subject to error, a standard linked list query solution can be used if a full query is required. Both of the above query methods quickly return the latest data, especially for existing historical data. Linked list queries are slow, and Bloom filters are an optimized data query solution that meets the needs of querying both hot and cold data.
[0074] The embodiment of the present invention aims to separate business and data, adopts data contracts as databases, and adds data factory contracts and data proxy contracts between application contracts and data contracts. The data proxy contract implements a reading and writing method compatible with historical existing data, and saves the data proxy contract in the form of a linked list, realizing a chain storage contract structure that separates business and data, thereby improving the efficiency of reading and writing contract data.
[0075] Example 2
[0076] Figure 5 This is a structural diagram of a blockchain smart contract data processing device 500 provided in one embodiment of this specification. Figure 5In one embodiment, an application contract, a data contract, and a data factory contract are deployed in a blockchain; wherein the application contract is used to issue transaction data processing instructions, the data contract is used to define relevant interfaces for transaction data processing, and the data factory contract is used to manage a data proxy contract, wherein the data proxy contract corresponds to the data contract and implements the interface of the data contract; the apparatus 500 includes:
[0077] The first module 501 is capable of creating and deploying a first data proxy contract to the blockchain by the data factory contract, and updating the current data proxy contract address of the data factory contract to the first data proxy contract address;
[0078] The second module 502 is configured to enable the application contract to call the data factory contract to obtain the address of the first data proxy contract, so that the application contract instructs the first data proxy contract to perform transaction data processing operations, wherein the transaction data processing operations include at least adding, modifying, and querying.
[0079] The third module 503 can determine whether a new data proxy contract needs to be deployed according to preset rules;
[0080] The fourth module 504 can create and deploy a second data proxy contract to the blockchain when a new data proxy contract needs to be deployed. The data factory contract updates the current data proxy contract address of the data factory contract with the second data proxy contract address. The second data proxy contract records the first data proxy contract address.
[0081] like Figure 6 As shown, another implementation of a blockchain smart contract data processing device 500 provided by an embodiment of the present invention is provided, wherein the data factory contract is further configured to uniformly receive instructions from the application contract; and the device 500 further includes:
[0082] The fifth module 505 can enable the data factory contract to call any data proxy contract to perform a transaction data query operation when the application contract issues a transaction data query instruction; when any data proxy contract fails to query the transaction data, it calls its previous data proxy contract to continue the query.
[0083] Furthermore, the data factory contract includes a Bloom filter and stores the Bloom vector value corresponding to each data contract; and when the application contract writes data to a data contract, the application contract updates the Bloom vector value of the corresponding data contract based on the key value of the data. The process of querying transaction data based on the Bloom filter includes: obtaining the key value of the data to be queried, and querying the latest data contract for the data to be queried based on the key value; if the corresponding data is not found in the latest data contract, the data factory contract queries the corresponding data contract for the data to be queried based on the Bloom vector value corresponding to the key value; and feeding back the transaction data query operation results to the application contract.
[0084] It should be understood that a blockchain smart contract data processing device according to the embodiment of this specification can also execute Figures 1 to 4 Method for executing a blockchain smart contract data processing device (or equipment) in Figures 1 to 4 The functions of the examples shown will not be described in detail here.
[0085] Example 3
[0086] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of this specification. Figure 7 At the hardware level, the electronic device includes a processor and, optionally, an internal bus, a network interface, and memory. The memory may include internal memory, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk drive. Of course, the electronic device may also include other hardware required for its services.
[0087] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or one type of bus.
[0088] The memory is used to store programs. Specifically, the program may include program code, which includes computer operating instructions. The memory may include internal memory and non-volatile memory, and provides instructions and data to the processor.
[0089] The processor reads the corresponding computer program from the non-volatile memory into the internal memory and then runs it, forming a shared resource access control device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0090] Deploy an application contract, a data contract, and a data factory contract in a blockchain; wherein the application contract is used to issue transaction data processing instructions, the data contract is used to define relevant interfaces for transaction data processing, and the data factory contract is used to uniformly receive the application contract instructions and manage the data proxy contract, wherein the data proxy contract corresponds to the data contract and implements the interface of the data contract; the method includes:
[0091] The data factory contract creates and deploys a first data proxy contract to the blockchain, and updates the current data proxy contract address of the data factory contract to the first data proxy contract address;
[0092] The application contract calls the data factory contract to obtain the address of the first data proxy contract, so that the application contract instructs the first data proxy contract to perform transaction data processing operations, where the transaction data processing operations include at least adding, modifying, and querying;
[0093] Determine whether a new data proxy contract needs to be deployed based on preset rules;
[0094] When a new data proxy contract needs to be deployed, the data factory contract creates and deploys a second data proxy contract to the blockchain, and updates the current data proxy contract address of the data factory contract with the second data proxy contract address. The second data proxy contract records the first data proxy contract address.
[0095] The above is as in this manual Figures 1 to 4The blockchain smart contract data processing method disclosed in the illustrated embodiments can be applied to or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, the steps of the above method can be performed by hardware integrated logic circuits in the processor or by software instructions. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The methods, steps, and logic block diagrams disclosed in the embodiments of this specification can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of this specification can be directly implemented and executed by a hardware decoding processor or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above method.
[0096] Of course, in addition to software implementation, the electronic device of the embodiments of this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0097] Example 4
[0098] The embodiment of this specification also proposes a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including multiple application programs, can enable the portable electronic device to execute Figures 1 to 4 The blockchain smart contract data processing method of the illustrated embodiment is specifically used to perform the following methods:
[0099] Deploy an application contract, a data contract, and a data factory contract in a blockchain; wherein the application contract is used to issue transaction data processing instructions, the data contract is used to define relevant interfaces for transaction data processing, and the data factory contract is used to uniformly receive the application contract instructions and manage the data proxy contract, wherein the data proxy contract corresponds to the data contract and implements the interface of the data contract; the method includes:
[0100] The data factory contract creates and deploys a first data proxy contract to the blockchain, and updates the current data proxy contract address of the data factory contract to the first data proxy contract address;
[0101] The application contract calls the data factory contract to obtain the address of the first data proxy contract, so that the application contract instructs the first data proxy contract to perform transaction data processing operations, where the transaction data processing operations include at least adding, modifying, and querying;
[0102] Determine whether a new data proxy contract needs to be deployed based on preset rules;
[0103] When a new data proxy contract needs to be deployed, the data factory contract creates and deploys a second data proxy contract to the blockchain, and updates the current data proxy contract address of the data factory contract with the second data proxy contract address. The second data proxy contract records the first data proxy contract address.
[0104] In short, the above description is only a preferred embodiment of this specification and is not intended to limit the scope of protection of this specification. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this specification shall be included in the scope of protection of this specification.
[0105] The systems, devices, modules, or units described in the above embodiments may be implemented by computer chips or entities, or by products having certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0106] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0107] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0108] The various embodiments in this specification are described in a progressive manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiments are generally similar to the method embodiments, so the description is relatively simple. For relevant parts, refer to the description of the method embodiments.
Claims
1. A blockchain smart contract data processing method, characterized in that: Deploy an application contract, a data contract, and a data factory contract in a blockchain; wherein the application contract is used to issue transaction data processing instructions, the data contract is used to define relevant interfaces for transaction data processing, and the data factory contract is used to manage a data proxy contract, wherein the data proxy contract corresponds to the data contract and implements the interface of the data contract; the method includes: The data factory contract creates and deploys a first data proxy contract to the blockchain, and updates the current data proxy contract address of the data factory contract to the first data proxy contract address; The application contract calls the data factory contract to obtain the address of the first data proxy contract, so that the application contract instructs the first data proxy contract to perform transaction data processing operations, where the transaction data processing operations include at least adding, modifying, and querying; Determine whether a new data proxy contract needs to be deployed based on preset rules; When a new data proxy contract needs to be deployed, the data factory contract creates and deploys a second data proxy contract to the blockchain, and updates the current data proxy contract address of the data factory contract with the second data proxy contract address. The second data proxy contract records the first data proxy contract address.
2. The blockchain smart contract data processing method according to claim 1, characterized in that: After the data factory contract creates and deploys the first data proxy contract to the blockchain, the application contract writes the first data contract address into the first data proxy contract.
3. The blockchain smart contract data processing method according to claim 2, characterized in that: The process of the application contract calling the data factory contract to obtain the first data proxy contract address so that the application contract instructs the first data proxy contract to perform the transaction data processing operation includes: The first data proxy contract executes the operation of adding and / or modifying transaction data; Based on the execution results of the transaction data addition and / or modification operations, the data factory contract updates the data storage capacity of the first data contract.
4. The blockchain smart contract data processing method according to claim 3 is characterized in that: Determining whether a new data proxy contract needs to be deployed based on preset rules includes: the preset rules include when a preset periodic timer is triggered; and / or, the data storage capacity of the first data contract is greater than or equal to a storage capacity threshold.
5. The blockchain smart contract data processing method according to claim 4 is characterized in that: When a new data proxy contract needs to be deployed, the data factory contract creates and deploys a second data proxy contract to the blockchain, including: creating the second data proxy contract based on the second data contract address and the first data proxy contract address.
6. The blockchain smart contract data processing method according to claim 1, characterized in that: The data factory contract is also used to uniformly receive instructions from the application contracts; and also includes: when the application contract issues a transaction data query instruction, the data factory contract calls any data proxy contract to perform a transaction data query operation; when any data proxy contract fails to query the transaction data, it calls its previous data proxy contract to continue the query.
7. The blockchain smart contract data processing method according to claim 6, characterized in that: The data factory contract includes a Bloom filter and stores a Bloom vector value corresponding to each data contract; and when the application contract writes data to the data contract, the application contract updates the Bloom vector value of the corresponding data contract based on the key value of the data.
8. The blockchain smart contract data processing method according to claim 7, characterized in that: The process of querying transaction data based on Bloom filters includes: Obtain the key value of the data to be queried, and query the data to be queried in the latest data contract based on the key value; If the corresponding data is not found in the latest data contract, the data factory contract will query the data to be queried in the corresponding data contract based on the bloom vector value corresponding to the key; Feedback transaction data query operation results to the application contract.
9. A blockchain smart contract data processing device, characterized in that: An application contract, a data contract, and a data factory contract are deployed in a blockchain; wherein the application contract is used to issue transaction data processing instructions, the data contract is used to define relevant interfaces for transaction data processing, and the data factory contract is used to manage a data proxy contract, wherein the data proxy contract corresponds to the data contract and implements the interface of the data contract; the apparatus comprises: A first module is configured to create and deploy a first data proxy contract to the blockchain from the data factory contract, and to update the current data proxy contract address of the data factory contract to the first data proxy contract address; The second module is configured to enable the application contract to call the data factory contract to obtain the address of the first data proxy contract, so that the application contract instructs the first data proxy contract to perform transaction data processing operations, wherein the transaction data processing operations include at least adding, modifying, and querying; The third module can determine whether a new data proxy contract needs to be deployed based on preset rules; The fourth module can create and deploy a second data proxy contract to the blockchain by the data factory contract when a new data proxy contract needs to be deployed, and update the current data proxy contract address of the data factory contract to the second data proxy contract address, and the second data proxy contract records the first data proxy contract address.
10. The blockchain smart contract data processing device according to claim 9, characterized in that: The data factory contract is further configured to uniformly receive instructions from the application contract; and further includes: The fifth module enables the data factory contract to call any data proxy contract to perform a transaction data query operation when the application contract issues a transaction data query instruction; when any data proxy contract fails to query the transaction data, it calls its previous data proxy contract to continue the query.
11. The blockchain smart contract data processing device according to claim 10, characterized in that: The data factory contract includes a Bloom filter and stores a Bloom vector value corresponding to each data contract; and when the application contract writes data to the data contract, the application contract updates the Bloom vector value of the corresponding data contract based on the key value of the data.
12. The blockchain smart contract data processing method according to claim 11, characterized in that: The process of querying transaction data based on Bloom filters includes: Obtain the key value of the data to be queried, and query the data to be queried in the latest data contract based on the key value; If the corresponding data is not found in the latest data contract, the data factory contract will query the data to be queried in the corresponding data contract based on the bloom vector value corresponding to the key; Feedback transaction data query operation results to the application contract.
13. An electronic device, characterized in that: include: processor; And a memory arranged to store computer-executable instructions, which, when executed, cause the processor to execute the blockchain smart contract data processing method according to any one of claims 1 to 8.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium stores one or more programs, which, when executed by an electronic device including multiple application programs, enable the electronic device to execute the blockchain smart contract data processing method described in any one of claims 1 to 8.
Citation Information
Patent Citations
Data creation method and device based on smart contract, equipment and storage medium
CN111159301A
Data processing method and device based on block chain system and electronic equipment
CN112232961A