Data processing method and device based on block chain, electronic equipment and storage medium
By introducing multi-dimensional heterogeneous storage systems and storage contracts into the blockchain and selecting storage media based on data characteristics, the efficiency and security issues in existing blockchain storage solutions are solved, and efficient and flexible data storage and system performance improvement are achieved.
Patent Information
- Application Number
- CN202410350107.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-22
- Publication Date
- 2025-09-23
AI Technical Summary
Existing blockchain storage solutions ignore the impact of different data characteristics on storage efficiency, resulting in delays and resource waste. In addition, the storage logic is tightly coupled with smart contracts, making it difficult to cope with complex security and scalability requirements.
A multi-dimensional heterogeneous storage system is adopted, and suitable storage media are selected according to data characteristics through storage contracts. The blockchain consensus mechanism is combined to ensure the correctness and flexibility of data storage, and the storage strategy is dynamically adjusted to adapt to different needs.
It improves the efficiency and flexibility of blockchain data storage, improves system performance and scalability, ensures the correctness and security of data storage, and adapts to the ever-changing market and technological environment.
Smart Images

Figure CN120687022A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and specifically to a blockchain-based data processing method and device, electronic device, and computer-readable storage medium. Background Art
[0002] Smart contracts currently deployed in blockchain systems are typically used to process business logic calculations. The transaction results obtained from executing a smart contract include a read-write set. The read set contains the data read during the smart contract execution, while the write set contains the data to be written to the blockchain after the smart contract execution.
[0003] Existing blockchain storage solutions typically use a single storage system to store all data types, such as a key-value database or other database. After executing a business transaction, smart contracts directly store the write-set data in a single storage system. However, this storage approach ignores the impact of varying data characteristics on storage efficiency. For example, using traditional hard drives for data that requires rapid access can result in latency, while using high-performance storage for large amounts of infrequently accessed data can waste resources.
[0004] Therefore, how to improve the storage efficiency of data in the blockchain is a technical problem that technicians in this field need to solve. Summary of the Invention
[0005] To solve the above technical problems, the embodiments of the present application provide a blockchain-based data processing method and device, an electronic device, a computer-readable storage medium, and a computer program product to improve the storage efficiency of data in the blockchain.
[0006] One aspect of an embodiment of the present application provides a blockchain-based data processing method, the method comprising: executing a business transaction through a computing contract to obtain a business transaction execution result, wherein the computing contract is a smart contract used to process business logic calculations; executing storage allocation of write-set data in the business transaction execution result through a storage contract to obtain a storage method of the write-set data in a multi-dimensional heterogeneous storage system, wherein the multi-dimensional heterogeneous storage system is composed of multiple storage media, and the storage contract is a smart contract used to select a storage medium suitable for data storage according to a preset storage strategy; and storing the write-set data in the multi-dimensional heterogeneous storage system according to the storage method corresponding to the write-set data.
[0007] Another aspect of an embodiment of the present application provides a blockchain-based data processing device, which includes: a computing contract execution module, configured to execute a business transaction through a computing contract to obtain a business transaction execution result, wherein the computing contract is a smart contract for processing business logic calculations; a storage contract execution module, configured to execute storage allocation of write-set data in the business transaction execution result through a storage contract to obtain a storage method of the write-set data in a multi-dimensional heterogeneous storage system, wherein the multi-dimensional heterogeneous storage system is composed of multiple storage media, and the storage contract is a smart contract for selecting a storage medium suitable for data storage according to a preset storage policy; and a data storage module, configured to store the write-set data in the multi-dimensional heterogeneous storage system according to the storage method corresponding to the write-set data.
[0008] Another aspect of an embodiment of the present application provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device implements the blockchain-based data processing method as described above.
[0009] Another aspect of an embodiment of the present application provides a computer-readable storage medium having computer-readable instructions stored thereon. When the computer-readable instructions are executed by a processor of a computer, the computer executes the blockchain-based data processing method as described above.
[0010] Another aspect of an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the blockchain-based data processing method as described above.
[0011] In the technical solution provided in the embodiments of the present application, not only a computing contract but also a storage contract is deployed on the blockchain node. The write-set data of the business transaction executed by the computing contract is not simply stored in a single storage system. Instead, the storage method of the write-set data in the multi-dimensional heterogeneous storage system is obtained through the execution of the storage contract, and the write-set data is stored in different storage media according to the obtained storage method. Therefore, through the storage contract's storage allocation of the write-set data, the write-set data can be stored in a suitable storage medium according to the characteristics and storage requirements of the data, thereby improving the storage efficiency and flexibility of the data.
[0012] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 This is a schematic diagram of the structure of a blockchain system shown in an exemplary embodiment;
[0014] Figure 2 This diagram illustrates the system architecture corresponding to the blockchain data storage solution proposed in this application;
[0015] Figure 3 It illustrates the flow chart of interactions between different modules in a blockchain node;
[0016] Figure 4 This diagram illustrates the decoupling relationship between the computation contract and the storage contract.
[0017] Figure 5 Illustrate exemplary information of the contract call interface provided by different storage media;
[0018] Figure 6 This is a flowchart of a data processing method based on blockchain, shown in an exemplary embodiment of the present application;
[0019] Figure 7 A diagram illustrating the execution results of the calculation contract and storage contract for business transactions;
[0020] Figure 8 is based on Figure 6 A flowchart of another blockchain-based data processing method further proposed in the illustrated embodiment;
[0021] Figure 9 is based on Figure 6 A flowchart of another blockchain-based data processing method further proposed in the illustrated embodiment;
[0022] Figure 10 A flowchart illustrating another blockchain-based data processing method;
[0023] Figure 11 This diagram illustrates the deployment process of the storage contract on the blockchain;
[0024] Figure 12 A schematic diagram illustrating the processing flow of business transactions;
[0025] Figure 13 is a block diagram of a data processing device based on blockchain, shown in an exemplary embodiment;
[0026] Figure 14 A schematic diagram of the structure of a computer system suitable for implementing an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0027] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. When the following description refers to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0028] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0029] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.
[0030] In this application, "plurality" refers to two or more. "And / or" describes the relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.
[0031] The terms "first," "second," "third," and "fourth," etc., in the specification and claims of this application and the accompanying drawings are used to distinguish different objects, not to describe a specific order. The terms "including," "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or elements is not limited to the listed steps or elements, but may optionally include steps or elements not listed, or may optionally include other steps or elements inherent to the process, method, product, or apparatus.
[0032] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0033] First of all, it should be noted that the embodiments of the present application involve blockchain technology. Blockchain technology is a new distributed infrastructure and computing method that uses a block chain data structure to verify and store data, a distributed node consensus algorithm to generate and update data, cryptography to ensure the security of data transmission and access, and smart contracts composed of automated script code to program and operate data. Blockchain refers to a decentralized infrastructure with distributed storage characteristics. Specifically, it is a data structure that organizes data blocks in a chronological order in a manner similar to a linked list. It can securely store data that has a sequential relationship and can be verified within the system, and uses cryptography to ensure that the data cannot be tampered with or forged. Simply put, blockchain is a decentralized distributed ledger, and each chain is equivalent to an independent ledger.
[0034] Figure 1 This is a schematic structural diagram of a blockchain system shown in an exemplary embodiment. Figure 1 The blockchain system 100 shown may include node devices 10a, 10b, 10c, and 10d. Node devices 10a, 10b, 10c, and 10d are all Figure 1 The blockchain nodes (referred to as nodes for short) in the blockchain system 100 shown may be any form of computing device connected to the blockchain system 100, such as a server, a user terminal, etc. Figure 1 The node devices 10a, 10b, 10c, and 10d shown can also be connected through network communication to form a blockchain system 100.
[0035] Figure 1 The types of blockchains involved in the illustrated blockchain system 100 architecture may include: public blockchain, private blockchain, and consortium blockchain. The types of blockchains employed in different blockchain application scenarios may vary and are not limited here. A public blockchain is a publicly accessible blockchain that anyone can join and access. Blockchains on a public blockchain are viewable, anyone can initiate transactions, and anyone can participate in the public blockchain's consensus process at any time. A private blockchain is designed for use within a private organization. Read, write, and account-keeping permissions on the blockchain can be determined according to the organization's rules. These blockchains are typically used for internal enterprise data management and auditing. A consortium blockchain is a blockchain where members' read, write, and account-keeping permissions are determined according to the consortium's rules. These blockchains are typically used for inter-institutional transactions, settlement, or clearing.
[0036] Each node in the blockchain system 100 has a corresponding node identifier, and each node in the blockchain system 100 can store the node identifiers of other nodes in the blockchain system 100, so that the generated blocks can be broadcast to other nodes in the blockchain system 100 based on the node identifiers of other nodes. Each node in the blockchain system 100 stores the same blockchain (see Figure 1 The blockchain 10e shown, therefore the blockchain system 100 can also be called a data sharing system.
[0037] A smart contract is a computer protocol designed to communicate, verify, or execute contracts in an information-based manner. Smart contracts allow for trusted transactions without a third party, and these transactions are traceable and irreversible. Smart contracts can be deployed on a blockchain to ensure transparency and security.
[0038] As mentioned earlier, smart contracts currently deployed in blockchain systems are generally used to process business logic calculations. Furthermore, the storage solution currently adopted by blockchain systems is to store all types of data in a single storage system. After executing a business transaction, the smart contract directly uses the "PutState" operation to save the write-set data. The write-set data is saved by default to a predefined storage system, such as a key-value database or other database.
[0039] Existing blockchain data storage solutions clearly ignore the impact of different data characteristics on storage efficiency. For example, using traditional hard drives to store data that needs to be accessed quickly can cause latency, while using high-performance storage methods for large amounts of infrequently accessed data can easily waste resources. Consequently, existing solutions are limited in terms of storage efficiency and flexibility.
[0040] In existing solutions, the storage logic for write-set data is tightly coupled with the business logic of smart contracts, potentially threatening the security and consistency of storage operations. For example, since the storage operation stores write-set data in the database immediately after obtaining it, without undergoing independent verification and consensus, malicious nodes or code vulnerabilities in the blockchain system could compromise data integrity. Consequently, existing solutions struggle to meet complex security requirements.
[0041] Furthermore, existing blockchain systems are often designed with the current technological and market environment in mind. However, over time, blockchain systems may need to support more data types, process larger data volumes, or adapt to new business needs. However, due to the single storage logic of existing solutions, expanding or upgrading the storage system may require restructuring the entire blockchain system, which not only consumes resources but may also cause downtime or performance degradation. Therefore, existing solutions also suffer from limited scalability and adaptability.
[0042] To address one or more of the above issues with existing solutions, the present invention proposes a novel blockchain data storage solution. This solution is coordinated by a multi-dimensional heterogeneous storage system composed of various storage media, such as local cache, distributed cache, key-value database, text database, and relational database, without limitation.
[0043] In this solution, the write-set data of a smart contract is not simply stored in a predefined storage system. Instead, another new type of smart contract (i.e., storage contract) manages the storage of data in a multi-dimensional heterogeneous storage system. The storage contract can store data in suitable storage media based on the data's characteristics (such as size, access frequency, security requirements, etc.). For example, frequently accessed data can be stored in a local cache with a faster read rate, while infrequently accessed large data can be stored in a persistent cache with a lower cost. Therefore, based on this dynamic adaptation mechanism of storage media, data storage efficiency can be significantly improved, thereby improving the overall performance of the blockchain system.
[0044] In this solution, the data storage process itself can also be constrained by the blockchain consensus mechanism. All storage operations (i.e., the execution results of the storage contract) must be verified and agreed upon by blockchain nodes, thereby ensuring the correctness and immutability of storage. The deployment of the storage contract can also be constrained by the blockchain consensus mechanism, further ensuring the correctness and immutability of storage operations.
[0045] Furthermore, storage contracts can dynamically select storage media suitable for different data based on preset storage strategies. The contractualization of storage strategies means that these strategies themselves are also implemented and managed through smart contracts, and are also protected by security and consistency, thereby reducing errors and security vulnerabilities in the data storage process. The contractualization of storage strategies also makes the storage logic highly flexible and editable. For example, not only can the storage strategy in the smart contract be optimized based on the current system status and storage medium performance, but it can also be quickly adjusted in different application scenarios and when needs change, thereby improving the storage efficiency and performance of the entire blockchain system.
[0046] Furthermore, storage contracts and multi-dimensional heterogeneous storage systems provide blockchain systems with improved scalability. For example, as the system evolves and data volumes grow, new storage media can be added and storage contracts updated to accommodate new needs without requiring a large-scale reconstruction of the entire blockchain system. This scalability also enables blockchain systems to better adapt to changing market and technological environments while maintaining efficient and stable operation.
[0047] The following is a detailed explanation of the new blockchain data storage solution proposed in this application.
[0048] See also Figure 2 , Figure 2 The system architecture diagram corresponding to the blockchain data storage solution proposed in this application is shown, and the architecture diagram of one of the blockchain nodes is shown in detail. Figure 2 As shown, a blockchain node may include a network module 210, a verification module 220, a transaction pool module 230, a scheduling module 240, a consensus module 250, a storage module 260, a multi-dimensional heterogeneous storage system 270, and a block ledger 280. The functional implementation of each module will be described in detail below.
[0049] The network module 210 is used for communication between blockchain nodes, including data transmission and reception. It ensures the connectivity of the blockchain network and the efficiency of data transmission by handling network-level functions such as node discovery, data synchronization, and message broadcasting.
[0050] Verification module 220 is used to verify the legitimacy of transactions and blocks. It can include two submodules: an identity verification submodule and a permission verification submodule. The identity verification submodule verifies the identity of the node or user, ensuring that the source of the transaction or message is authentic. The permission verification submodule verifies whether the entity initiating the transaction has the authority to execute the transaction, preventing unauthorized operations.
[0051] The transaction pool module 230 is used to store transactions circulating on the network that have not yet been included in blocks, thereby implementing the transaction pool function. It can be understood that the transaction pool (also known as the memory pool) is a data structure in the blockchain network that stores pending transactions that have not yet been included in blocks. When a user submits a new transaction to the blockchain network, it first enters the transaction pool. When a blockchain node prepares to generate a new block, it selects a certain number of transactions from the transaction pool to be included in the transaction pool. The transaction pool allows nodes to collect and manage pending transactions and provides raw materials for block generation, helping to improve the processing capacity of the blockchain network.
[0052] The scheduling module 240 is used for the core logic of the blockchain node, including transaction processing and block generation. It can include a block generator, a transaction scheduling submodule, a computing contract repository, and a computing contract process pool. The block generator is used to generate new blocks, package transactions in the transaction pool into blocks, and perform the necessary verification and consensus processes. The transaction scheduling submodule is used to manage the execution order and resource allocation of transactions to ensure that transactions can be processed efficiently. The computing contract repository is used to store computing smart contract code deployed on the blockchain for call during blockchain node execution. The computing contract process pool submodule is used to manage the execution environment of computing contracts and allow concurrent execution of multiple computing contracts. It should be understood that the computing contracts disclosed in this application are smart contracts used for business logic calculations, that is, the smart contracts commonly deployed in the existing blockchain systems described above.
[0053] The consensus module 250 is used to implement the consensus mechanism of the blockchain, such as PoW (Proof of Work), PoS (Proof of Stake), PBFT (Practical Byzantine Fault Tolerance), etc., to ensure that all nodes in the blockchain network reach a consensus on the state of the blockchain.
[0054] Storage module 260 handles all operations related to data storage. It may include a transaction storage parsing submodule, a storage contract repository, a storage contract process pool, and a multi-dimensional heterogeneous storage system. The transaction storage parsing submodule parses the write-sets in transaction execution results and determines how to store this data. The storage contract repository stores the storage contract code deployed on the blockchain and manages the data storage logic. The storage contract process pool manages the execution environment of the storage contract, allowing for the concurrent execution of multiple storage contracts. It is understood that a storage contract is a smart contract that selects a storage medium suitable for data storage based on a preset storage policy. It specifies the type of storage medium on which data should be stored, as well as the data storage format and structure. The execution results of the storage contract are also recorded on the blockchain, ensuring the transparency and immutability of the storage process.
[0055] Multidimensional heterogeneous storage systems are composed of a variety of storage media, including local caches, persistent caches, distributed caches, key-value databases, text databases, and relational databases. These can be physically distinct storage devices or logically distinct storage systems. The different storage media that make up a multidimensional heterogeneous storage system each have unique characteristics, such as read / write performance, data persistence, and scalability. For example, local caches provide fast data access and are suitable for frequent read / write scenarios; persistent caches ensure data remains available after system restarts; distributed caches provide data sharing and redundancy across multiple nodes; key-value databases are simple databases for storing key-value data, suitable for fast searches; text databases are used to store text-formatted data, such as logs and configuration files; and relational databases are used to store structured data, supporting complex queries and transactions. Storage contracts can select the contract's storage medium for data storage based on the characteristics of the data and application requirements.
[0056] The Blockchain Ledger 270 is used to record all verified and agreed-upon blocks and is the core data structure of the blockchain. Organized in a chain-like structure, each block contains a set of transactions, a block header (including metadata such as the previous block's hash value and timestamp), and other information. The Blockchain Ledger 270 provides a public, immutable record of transaction history for the blockchain system, thereby ensuring system transparency and consistency.
[0057] It should be noted that Figure 2 The system architecture shown in the example is only an example. In actual application scenarios, corresponding modules can be selected and deployed in the blockchain node according to specific application requirements. This does not mean that the blockchain node can only be implemented as Figure 2 For example, in some application scenarios where the processing power of the blockchain network is required to be high, the transaction pool module 230 may not be provided. However, it should be understood that the scheduling module 240 and the storage module 260 are the core modules of the technical solution of this application, and therefore the scheduling module 240 and the storage module 260 are usually indispensable in the blockchain node.
[0058] based on Figure 2 Schematic system architecture, Figure 3 It further illustrates the interaction process between different modules in the blockchain node. Figure 3As shown in the figure, for a pending business transaction, the transaction scheduling submodule obtains the computing contract used to execute the business transaction, and then starts the corresponding computing contract process from the computing contract warehouse to execute the business transaction. Since it is necessary to store the write-set data of the computing contract executing the business transaction, it is necessary to determine the corresponding storage contract and start the corresponding storage contract process to perform the storage allocation of the write-set data, so as to allocate the write-set data to the appropriate storage medium for storage according to the preset storage strategy. Subsequently, in the process of generating a new block, the execution result of the storage contract will also be saved in the new block, and the new block will be stored in the block ledger after passing the consensus.
[0059] Therefore, by deploying computation contracts and storage contracts on blockchain nodes, not only can computation contracts be used to execute specific business logic calculations, but the storage contracts can also be used to manage the storage of the computation contract execution results. This allows data to be stored in the most suitable storage medium, improving the storage efficiency and flexibility of blockchain data. The execution results of the storage contract also need to be saved on the blockchain ledger after consensus, so that the data storage operation itself is also subject to consensus of the blockchain network, which can ensure the accuracy and immutability of data storage.
[0060] And by Figure 3 The process shown in the figure also shows that the computing contract and the storage contract are also decoupled. To better understand the decoupling relationship between the computing contract and the storage contract, please refer to Figure 4 This diagram illustrates the decoupled relationship between the computation contract and the storage contract. The computation contract and storage contract are separate smart contracts that can be linked. This association can be achieved by binding the computation contract to the storage contract methods it can call. For example, the computation contract can specify one or more storage contract methods for storage, and storage contract methods can be bound to a key in the computation contract for associated storage. For example, computation contract 1 represents user A's balance as contract1-keyA-value. A storage contract method can be bound to contract1, ensuring that all writesets executed by contract1 will call the bound storage contract method. Alternatively, a storage contract method can be bound to contract1-keyA, down to the granularity of keyA, ensuring that all writesets executed by contract1 involving user A will call the bound storage contract method. This decoupling of the computation contract and storage contract allows for a high degree of flexibility and editability in the storage logic of blockchain data.
[0061] Different media in a multi-dimensional heterogeneous storage system provide different contract call interfaces, such as contract SDK (Software Development Kit) interfaces, so that storage contracts can obtain necessary information based on these contract call interfaces to make relevant judgments and decide which storage medium to store the data in.
[0062] Figure 5 This section illustrates exemplary information about contract call interfaces provided by different storage media. For example, the local cache provides contract call interfaces for querying the recent average query duration, recent query count, memory usage, and stored data. The storage contract can call these interfaces to obtain the current status of the local cache and, based on the obtained status information, determine whether to store the data in the local cache. For another example, the distributed cache provides contract call interfaces for querying the recent average query duration, recent query count, number of distributed nodes, database size, and stored data. The storage contract can call these interfaces to obtain the current status of the distributed cache and, based on the obtained status information, determine whether to store the data in the distributed cache.
[0063] Based on Figure 2-5 The illustrated system architecture and related interaction processes, the embodiments of the present application also respectively propose a blockchain-based data processing method, a blockchain-based data processing device, an electronic device, a computer-readable storage medium and a computer program product, which will be introduced in detail below.
[0064] See Figure 6 , Figure 6 This is a flowchart of a data processing method based on blockchain, which is an exemplary embodiment of the present application. This method can be specifically executed by a blockchain node to implement relevant processing for blockchain transactions.
[0065] like Figure 6 As shown, the method includes S610-S630, which are described in detail as follows:
[0066] S610, executing the business transaction by calculating the contract and obtaining the business transaction execution result.
[0067] Computation contracts are smart contracts used to process business logic, so computation contracts are also common contracts in existing blockchain systems.
[0068] Business transactions can be initiated by clients and, after verification by blockchain nodes and passing verification, stored in the transaction pool as pending transactions that have not yet been packaged into a block. When preparing to generate a new block, blockchain nodes will select a certain number of transactions from the transaction pool for packaging and processing, thereby helping to improve the processing capacity of the blockchain network. Of course, in some exemplary embodiments, business transactions initiated by clients can also be stored in the transaction pool, for example, waiting directly for blockchain node processing. This embodiment is not limited to storing business transactions in the transaction pool.
[0069] Exemplarily, a blockchain node receives a business transaction processing request from a client. The business transaction processing request contains the content information and signature information of the business transaction, where the signature information is obtained by performing signature processing on the content information. The node then authenticates the client based on the content information and signature information of the business transaction to ensure that the source of the business transaction is trustworthy. After passing the authentication, the node proceeds to verify the client's permissions, that is, to verify whether the client has the permission to execute the business transaction to prevent unauthorized operations. After passing the permission verification, the business transaction is stored in the transaction pool. In some exemplary embodiments, whether to perform client identity authentication or permission verification can also be selected based on actual application requirements, and this embodiment does not limit this.
[0070] Computation contracts are stored in a computational contract repository. The computational contract repository is a centralized storage of contract code for different computational contracts on blockchain nodes. The computational contract repository stores computational contract code deployed on the blockchain for blockchain node execution. Blockchain nodes execute business transactions using computational contracts by launching computational contract processes from a computational contract process pool. The computational contract process pool is used to concurrently execute multiple computational contracts. It is understood that computational contract processes in the computational contract process pool are launched using the computational contract code in the computational contract repository.
[0071] The business transaction execution result obtained by the computing contract execution business transaction contains a read-write set, where the read set contains the set of data read during the computing contract execution business transaction, and the write set contains the set of data to be written to the blockchain after the computing contract is executed. Figure 7 This is a schematic diagram of the execution results of an exemplary business transaction at different contract execution stages, for example Figure 7 As shown, the business transaction execution result obtained by the calculation contract executing the business transaction contains not only the read set data "readSet" but also the write set data "writeSet".
[0072] S620: By allocating the write-set data in the transaction results of the storage contract, the storage method for the write-set data in the multi-dimensional heterogeneous storage system is obtained. The multi-dimensional heterogeneous storage system is composed of multiple storage media. The write-set data after the calculation contract executes the business transaction needs to be stored on the blockchain. In existing solutions, blockchain-based systems use a single storage system, such as a key-value database, and directly store the write-set data in the storage system through the "PutState" operation. In this embodiment, the storage method for the write-set data in the multi-dimensional heterogeneous storage system is obtained by executing the storage allocation of the write-set data through another new type of smart contract, namely the storage contract.
[0073] The multi-dimensional heterogeneous storage system is composed of a variety of storage media, including, for example, local cache, persistent cache, distributed cache, key-value database, text database, and relational database, etc., which are not listed here one by one. The functions and characteristics of these exemplary storage media have been described in the above embodiments and will not be repeated here.
[0074] A storage contract is a smart contract used to select storage media suitable for data storage based on a pre-set storage policy. A storage policy is a set of rules or guidelines that govern how and where data is stored in a multi-dimensional, heterogeneous storage system. Specifically, a storage policy determines how data is distributed across different storage media and how data storage is optimized based on data access patterns, security requirements, and performance needs to ensure efficient and reliable data storage.
[0075] For example, the storage contract can obtain the status information of various storage media according to the contract call interface of various storage media, so as to allocate the storage of the write-set data in the business transaction execution result according to the status information of various storage media and the preset storage strategy, so as to obtain the storage method corresponding to the write-set data. Figure 5 For example, each storage medium provides at least one contract calling interface, so that the storage contract can obtain the status information of the corresponding storage medium by calling these contract calling interfaces, such as the recent average query time, content occupancy size, storage data and other status information of the local cache, and the recent average query time, recent query times, content occupancy size, storage occupancy size, storage data and other status information of the persistent cache.
[0076] For example, the storage policy preset in a storage contract may include: if the data itself satisfies a certain constraint, and the current state of a certain storage medium satisfies the constraint, then the data is stored in a certain storage medium. Thus, blockchain nodes can allocate each write-set data item in the business transaction execution result to an appropriate storage medium for storage based on the status information of various storage media and the preset storage policy. It should be noted that the storage policy is used to store data in an appropriate storage medium based on data characteristics and storage requirements. On this basis, the storage policy preset in the storage contract can be set according to the actual application scenario, and this embodiment does not limit the specific content of the policy.
[0077] It should also be noted that this embodiment obtains the storage method of the write-set data in the multi-dimensional heterogeneous storage system by allocating the storage of the write-set data in the execution result of the storage contract execution business transaction. The storage method corresponding to the write-set data can be understood as how to store the data, so that the storage contract can dynamically select and adapt to different storage media. For example, Figure 7 The execution result of the storage contract in the example shows that the write set data with the key "balance0f:0x11111111111111111111111111111111" can be allocated to the local cache "LocalCache" through the local cache contract "LocalCacheStorageContract", and the write set data with the key "balance0f:0x22222222222222222222222222222222" can be allocated to the key-value database "KeyValueStore" through the key-value database contract "LocalCacheStorageContract".
[0078] S630 , storing the write-set data in a multi-dimensional heterogeneous storage system according to a storage method corresponding to the write-set data.
[0079] As can be seen from the above, the execution result of the storage contract not only contains information about the storage medium suitable for each write-set data, but also contains information on how to store the write-set data in the corresponding storage medium. Therefore, according to the storage method corresponding to the write-set data obtained through the storage contract, the write-set data can be stored in the corresponding storage medium included in the multi-dimensional heterogeneous storage system.
[0080] In the technical solution proposed in this embodiment, compared with the existing solution, not only a computing contract but also a storage contract is deployed on the blockchain node. The write-set data of the business transaction executed by the computing contract is not simply stored in a single storage system. Instead, the storage method of the write-set data in the multi-dimensional heterogeneous storage system is obtained through the execution of the storage contract, and the write-set data is stored in different storage media according to the obtained storage method. Therefore, through the storage contract's storage allocation of the write-set data, the write-set data can be stored in a suitable storage medium according to the characteristics and storage requirements of the data. For example, frequently accessed data can be stored in a local cache with a faster reading rate, and infrequently accessed large data can be stored in a lower-cost persistent cache. Therefore, based on this dynamic adaptation mechanism of the storage medium, the storage efficiency and flexibility of the blockchain data can be significantly improved, thereby improving the overall performance of the blockchain system.
[0081] Furthermore, because storage contracts are essentially smart contracts, the storage logic is encoded within them and subject to the same security and consistency guarantees, reducing errors and security vulnerabilities during data storage. The contractual nature of storage policies also makes the storage logic highly flexible and editable. Storage contracts and multi-dimensional heterogeneous storage systems also provide improved scalability for blockchain systems.
[0082] Figure 8 is based on Figure 6 The flowchart of another data processing method based on blockchain is further proposed in the embodiment shown. Figure 8 As shown, this method Figure 6 The embodiment shown further includes S810-S820, which are described in detail as follows:
[0083] S810: Generate a new block based on the business transaction execution results and the storage method corresponding to the write-set data, and perform consensus processing on the new block.
[0084] The execution result of the calculation contract is further executed through the storage contract. The execution result obtained further contains the storage method corresponding to the write set data based on the execution result of the calculation contract. For example, see Figure 7 As shown, each write-set data item corresponds to a suitable storage medium and a smart contract method for storing the write-set data in that storage medium. Therefore, the business transaction execution results and the corresponding storage methods for the write-set data mentioned in this embodiment can also be represented as the execution results of the storage contract. The execution results of the storage contract are packaged into blocks, thereby generating new blocks.
[0085] Blockchain nodes typically package the execution results of multiple transactions in the transaction pool into the same block to generate a new block. Therefore, this embodiment generates a new block based on the business transaction execution results and the corresponding storage method of the write-set data. This is not limited to packaging the execution results of a single business transaction to generate a new block. Instead, it indicates that each business contract included in the generated new block has been executed through the storage contract to obtain the corresponding execution result, and the execution result is packaged in the block.
[0086] During the consensus process of a new block, the blockchain master node forwards the new block to the blockchain slave node for consensus processing. The blockchain master node is also the blockchain node that executes the current method. Specifically, after the blockchain slave node receives the block sent by the blockchain master node, it first verifies the business transactions contained therein, then starts the same computing contract to execute the business transactions, and starts the same storage contract to further execute the execution results of the computing contract. It compares the execution results of the storage contract obtained by itself with the execution results of the storage contract in the blockchain master node to see if they are consistent, and then broadcasts the comparison results. Each consensus node learns whether the consensus is passed based on the received broadcast information. If the consensus is passed, the new block is saved on the block ledger for storage. It should be noted that this embodiment does not limit the specific consensus algorithm adopted, and it can be selected according to actual application requirements.
[0087] S820: After the new block passes the consensus, the new block is saved in the block ledger, and the write set data is stored in the multi-dimensional heterogeneous storage system according to the storage method corresponding to the write set data.
[0088] For the blockchain master node, after the new block passes the consensus, it is necessary to save the new blockchain on the block ledger, and store the write set data of the business transactions in the new block in the corresponding storage medium contained in the multi-dimensional heterogeneous storage system according to the storage method corresponding to the write set data.
[0089] In the technical solution provided in this embodiment, the data storage process itself is also subject to the constraints of the blockchain consensus mechanism. All storage operations, that is, the execution results of the storage contract, also need to be verified and agreed upon by the blockchain nodes, thereby ensuring the correctness and non-tamperability of data storage, enabling the blockchain system to cope with more complex security requirements.
[0090] In another exemplary embodiment, Figure 9 As shown, the process of the blockchain node allocating storage of the write-set data in the result of executing the business transaction through the storage contract and obtaining the storage method corresponding to the write-set data further includes S910-S930, which are detailed as follows:
[0091] S910, parsing the write set data contained in the business transaction execution result.
[0092] As mentioned above, the business transaction execution result contains read-write set data. Since the write-set data is data that needs to be stored on the blockchain, it is necessary to parse the business transaction execution result to extract the write-set data to be stored.
[0093] In some exemplary embodiments, the business transaction execution result contains multiple write-set data, so each write-set data needs to be parsed accordingly so that storage allocation can be performed for each write-set data separately through the storage contract.
[0094] S920: Determine a storage contract for executing storage allocation for write-set data.
[0095] Based on the aforementioned architecture of decoupling the compute contract from the storage contract, by obtaining the storage contract method bound to the compute contract, the storage contract used to allocate storage for the writeset data can be determined based on the obtained storage contract method. For example, the binding of a compute contract to a storage contract method can involve the compute contract specifying one or more storage contract methods for storage, or the storage contract method being bound to a key in the compute contract for associated storage.
[0096] In some exemplary embodiments, if there is no storage contract method bound to the computation contract, storage allocation is performed on the write-set data according to the default storage policy to obtain a storage method corresponding to the write-set data, so that the blockchain system has higher adaptability.
[0097] S930: Start the corresponding storage contract process from the storage contract process pool to execute storage allocation of the write-set data to obtain the storage method corresponding to the write-set data.
[0098] The storage contract process pool is used to execute multiple storage contracts concurrently. Therefore, by starting the corresponding storage contract process from the storage contract process pool to execute the storage allocation of the write set data, the storage method corresponding to the write set data can be obtained.
[0099] An example of the process of starting the corresponding storage contract process from the storage contract process pool is as follows:
[0100] First, the storage contract process pool is queried to see if it contains the corresponding storage contract process. Specifically, it queries whether there is an available storage contract process in the current storage contract process pool. If so, the queried storage contract process is launched to perform storage allocation for the write-set data. If not, the process waits for idle resources in the storage contract process pool. If so, the corresponding storage contract process is launched from the storage contract repository and added to the storage contract process pool. This launched storage contract process then performs storage allocation for the write-set data. It is understood that the storage contract repository is used to store the code for storage contracts deployed on the blockchain. Therefore, the storage contract code in the storage contract repository is required to launch the corresponding storage contract process. Therefore, based on the transaction storage parsing, storage contract repository, and storage contract process pool functions provided by blockchain nodes, the application and implementation of storage contracts in blockchain systems is ensured.
[0101] Figure 10 A flowchart of another data processing method based on blockchain is also shown. Figure 10 As shown, the method further includes S1010-S1020,
[0102] S1010, executing the deployment transaction through the system contract to obtain the deployment transaction execution result.
[0103] First of all, it should be noted that the system contract mentioned in this embodiment is another type of smart contract deployed on the blockchain, specifically a smart contract used to verify the contract code of the storage contract and the storage contract's usage rights for various storage media in the multi-dimensional heterogeneous storage system.
[0104] In this embodiment, the deployment of the storage contract is treated as a deployment transaction, which is executed through the system contract. The purpose is to verify the contract code of the storage contract to be deployed on the blockchain and the storage contract's permission to use various storage media in the multi-dimensional heterogeneous storage system through the system contract to obtain the corresponding deployment transaction execution result.
[0105] Exemplarily, the system contract verifies the syntax correctness and code executableness of the storage contract to be deployed. Once the verification passes, it then proceeds to verify the usage permissions of the storage media that the storage contract may call. Once the usage permissions pass the verification, a deployment transaction execution result is generated, indicating that the deployment transaction has been executed normally. Thus, by verifying the syntax correctness and code executableness of the storage contract to be deployed, the code correctness of the storage contract is ensured. Furthermore, by verifying whether the deployer of the storage contract has the permission to use the corresponding storage media, unauthorized operations on the blockchain system are prevented, thereby greatly ensuring the reliability of the blockchain system.
[0106] In another exemplary embodiment, after receiving a deployment transaction request from a client, the blockchain node performs identity authentication of the client based on the content information and signature information of the storage contract to be deployed contained in the deployment transaction request, and after passing the identity authentication, continues to perform permission verification of the client. After passing the permission verification, the deployment transaction is stored in the transaction pool as a pending transaction that has not yet been packaged into a block, so that subsequent blockchain nodes can select a certain number of transactions from the transaction pool for packaging when preparing to generate a new block.
[0107] S1020, generate a new block based on the storage contract to be deployed in the deployment transaction and the deployment transaction execution result. After the new block passes the consensus, save the new block on the block ledger, and determine whether the deployment transaction execution result indicates that the deployment transaction is executed normally. If so, store the storage contract in the storage contract warehouse.
[0108] When a blockchain node prepares to generate a new blockchain, if it needs to package a deployment transaction into a new block, it generates a new block based on the storage contract to be deployed in the deployment transaction and the deployment transaction execution result. It then forwards this new block to the blockchain slave nodes for consensus on the new block. It should be understood that during the consensus process, the blockchain node that initiates consensus on the new block serves as the blockchain master node. The blockchain master node sends the new block to be agreed upon to the blockchain slave nodes, which then activate the same system contract to process the deployment transaction contained in the new block. The master node then determines whether the deployment transaction execution result is consistent with the deployment transaction execution result of the blockchain master node. This determination is then broadcasted, and each blockchain node then determines whether the new block has passed consensus based on the received determination result.
[0109] After a new block reaches consensus, the blockchain nodes save it to the blockchain ledger. In other words, in the blockchain system, the deployment of the storage contract itself is considered a transaction, saved to the blockchain ledger after consensus. This further ensures the accuracy and immutability of blockchain data storage, and enhances the transparency and credibility of data storage.
[0110] The blockchain node also determines whether the deployment transaction execution result indicates that the deployment transaction was executed normally. If so, it means that the storage contract to be deployed has passed the system contract verification and is highly reliable and can be deployed on the blockchain. Therefore, the blockchain node stores the storage contract to be deployed in the storage contract repository. In other words, the storage contract code is saved in the storage contract repository for subsequent activation of the corresponding storage contract process to execute business transactions.
[0111] In some exemplary embodiments, considering that the code size of the storage contract to be deployed may be large, after the system contract verifies the storage contract to be deployed, the code of the storage contract to be deployed can also be compressed according to a preset compression method, so that the compressed storage contract is packaged in a new block to save processing and storage resources. In addition, before the storage contract code is stored in the storage contract repository, the compressed storage contract needs to be decompressed and the decompressed storage contract code is stored in the storage contract repository to ensure the reliability of the storage contract.
[0112] Therefore, in the technical solution provided in this embodiment, the deployment and execution of the storage contract are subject to the constraints of the blockchain consensus mechanism, which means that any storage operation needs to be verified and agreed upon by multiple nodes in the blockchain network, ensuring the correctness and non-tamperability of the storage operation.
[0113] In order to make it easier to understand the technical concept of the embodiments of the present application, two transaction processing processes of blockchain nodes are illustrated below, namely the processing process of deployment transactions and the processing process of business transactions.
[0114] It can be understood that the processing flow of deployment transactions is also the deployment process of storage contracts on the blockchain, and the processing flow of business transactions is also the entire process of the blockchain system using computing contracts to execute the logical calculations of business transactions, and using storage contracts to execute storage allocation for the write set data contained in the execution results of the computing contracts.
[0115] First, we will introduce the deployment process of the storage contract on the blockchain. Figure 11 As shown in the figure, the deployment process of the storage contract on the blockchain includes the following steps:
[0116] S1, start.
[0117] S2: The user writes the storage contract code on the client, packages the storage contract code and the contract initialization method parameters, and signs the packaged content. The packaged content and signature are sent together to the blockchain master node in the form of a request.
[0118] S3: The network module of the blockchain master node receives the above request.
[0119] In S4, the verification module of the blockchain node authenticates the above request. If the verification is successful, it jumps to S6. If the verification fails, it jumps to S5.
[0120] S5 returns the result of identity authentication failure and jumps to S23.
[0121] In S6, the verification module of the blockchain node continues to verify the permission of the above request. If the verification is passed, jump to S8; if the verification fails, jump to S7.
[0122] S7 returns the result of permission verification failure and jumps to S23.
[0123] S8, the block generator in the scheduling module of the blockchain node obtains the transaction for deploying the storage contract on the blockchain (hereinafter referred to as the deployment transaction) from the transaction pool, prepares to execute the deployment transaction and packages it into a new block.
[0124] S9, the transaction scheduling submodule in the scheduling module of the blockchain node starts the system contract to process the deployment transaction.
[0125] S10, the system contract verifies whether the syntax and code of the storage contract to be deployed are correct and executable. If so, jump to S12, otherwise jump to S11.
[0126] S11: The system contract returns an error indicating that the syntax and code of the storage contract are abnormal, and jumps to S14.
[0127] S12, the system contract verifies the storage medium that may be called by the storage contract to be deployed, and queries whether the deploying user has the authority to use the corresponding storage medium. If yes, jump to S14, otherwise jump to S13.
[0128] In S13, the system contract returns an error indicating that the user has insufficient permissions for the corresponding storage medium and jumps to S15.
[0129] S14: The system contract compresses the storage contract to be deployed and places the compressed storage contract into the execution result of the deployment transaction.
[0130] S15, the system contract writes the execution result of the deployment transaction into the new block.
[0131] S16, the block generator of the blockchain master node encapsulates the block and forwards the encapsulated new block to the blockchain slave node.
[0132] S17, after the blockchain receives the block from the node, it starts to verify the deployment transaction therein, starts the same system contract to execute the deployment transaction, and determines whether its own execution result is consistent with the execution result of the deployment transaction executed by the blockchain master node. If so, it recognizes the execution result of the deployment transaction by the blockchain master node, otherwise it does not recognize it.
[0133] In S18, all blockchain nodes broadcast and reach consensus on the new block. If the consensus is passed, jump to S19. If the consensus is not passed, jump to S22.
[0134] S19, all blockchain nodes append the latest block to the block ledger for storage.
[0135] S20, the blockchain master node determines whether the execution result of the system contract for the deployment transaction in the latest block is normal. If yes, jump to S21, otherwise jump to S22.
[0136] S21, decompress the execution result of the system contract for the storage contract to be deployed, and store the decompressed storage contract in the storage contract warehouse.
[0137] S22: For business transactions that still exist in the block, process them according to the processing logic of the business transactions.
[0138] S23, end.
[0139] As can be seen from the above process, the deployment of storage contracts on the blockchain also needs to be verified and agreed upon by nodes in the blockchain network. In other words, the deployment of storage contracts will also be constrained by the blockchain consensus mechanism, ensuring the correctness and non-tamperability of subsequent data storage operations performed using the storage contract, thereby ensuring the security of data storage and improving the reliability of the blockchain system.
[0140] See Figure 12 As shown, the processing flow of business transactions is as follows:
[0141] S1, start.
[0142] In S2, the user encapsulates the name and parameters of the smart contract to be called on the client, packages this information, signs the packaged content, and sends the packaged content and signature together in the form of a request to the blockchain master node.
[0143] S3: The network module of the blockchain master node receives the above request.
[0144] In S4, the verification module of the blockchain node authenticates the above request. If the verification is successful, it jumps to S6. If the verification fails, it jumps to S5.
[0145] S5 returns the result of identity authentication failure and jumps to S24.
[0146] In S6, the verification module of the blockchain node continues to verify the permission of the above request. If the verification is passed, jump to S8; if the verification fails, jump to S7.
[0147] S7 returns the result of permission verification failure and jumps to S24.
[0148] S8, the block generator in the scheduling module of the blockchain node obtains the business transaction from the transaction pool, prepares to execute the business transaction and packages it into a new block.
[0149] S9, the transaction scheduling submodule in the scheduling module of the blockchain node starts a computing contract process corresponding to a business transaction from the computing warehouse and puts it into the computing contract process pool, and executes the business transaction through the computing contract process.
[0150] S10, determine whether the execution result of the business transaction is successful, if yes, jump to S11, otherwise jump to S20.
[0151] S11, the scheduling module of the blockchain node sends the execution result of the business transaction to the storage module.
[0152] S12: The transaction storage parsing submodule of the storage module obtains all write sets from the execution results and determines whether the write set data has a corresponding storage contract name and method. If yes, jump to S13; otherwise, jump to S18.
[0153] S13, the storage module queries whether there is a storage contract process corresponding to the business transaction in the current storage contract process pool. If yes, jump to S15, otherwise jump to S14;
[0154] S14: When the storage module waits for the storage contract process pool to have free resources, it starts a corresponding contract process from the storage contract warehouse and puts it into the storage contract process pool.
[0155] S15: The storage contract process executes the storage allocation of the write set.
[0156] S16, determine whether the execution result is successful, if yes, jump to S17, otherwise jump to S18.
[0157] S17, write the execution result into the write set.
[0158] S18: Use the default storage policy and write the default storage policy into the write set.
[0159] S19, determine whether all write sets of the business transaction have been executed. If yes, jump to S20; otherwise, jump to S12.
[0160] S20, wait for all transactions to be executed, the block generator of the blockchain master node encapsulates the block and forwards it to the blockchain slave node for consensus.
[0161] S21, determine whether the consensus is passed, if yes, jump to S22, otherwise jump to S23.
[0162] S22, all blockchain nodes append the latest block to the block ledger for storage.
[0163] S23, all blockchain nodes store the transaction execution results according to the storage medium corresponding to the write set.
[0164] S24, end.
[0165] It should also be noted that the technical solutions proposed in the embodiments of this application can be applied to the following exemplary application scenarios.
[0166] For example, in supply chain management scenarios, storage contracts can be used to record and verify the flow of goods. Because supply chains involve multiple participants and complex data interactions, storage contracts can dynamically select appropriate storage media based on different types of data (such as goods status, location, and transaction records). For example, they can use cache to quickly access the current state of goods, while storing transaction records in a distributed database to ensure persistence and traceability. The consensus mechanism ensures that all participants agree on the data, enhancing transparency and trust in the supply chain.
[0167] For example, in financial services, transaction speed and data security are crucial. Storage contracts can select the most appropriate storage medium based on the transaction's characteristics and security requirements when executing financial transactions. For example, for high-frequency trading data, a low-latency local cache can be used; for long-term compliance records, a relational database can be used. Through on-chain verification and consensus protocols, all transactions are rigorously validated, ensuring the integrity and immutability of financial data.
[0168] In healthcare data management scenarios, medical data often involves personal privacy and requires a high degree of security and compliance. Storage contracts can manage patient medical records, dynamically selecting encrypted storage or private databases to protect sensitive information. Furthermore, storage contracts ensure that only authorized medical personnel can access specific data, while consensus mechanisms are used to verify data modifications and access, ensuring the security and privacy of medical data.
[0169] In IoT data processing scenarios, IoT devices generate massive amounts of data that needs to be processed and analyzed in real time. Storage contracts can allocate data to different storage media in real time based on the data generation rate and processing requirements. For example, real-time detection data can be temporarily stored in a cache for rapid analysis, while historical data can be transferred to lower-cost long-term storage media. Storage contracts can also automatically enforce data cleansing and archiving policies to optimize the use of storage resources.
[0170] For decentralized applications (DApps), storage contracts provide a flexible data storage solution that supports the diverse data and state management needs of DApps. For example, a social network DApp might require quick access to a user's latest status updates, while long-form blog content requires persistent storage. Storage contracts can automatically select the optimal storage medium based on content type and access patterns, and ensure data consistency and security through a consensus mechanism.
[0171] It should be noted that the application scenarios exemplified above demonstrate the broad applicability of the technical solutions proposed in the embodiments of this application, particularly in areas requiring efficient, secure, and reliable data storage management. The smart contract-based storage management and consensus verification proposed in the embodiments of this application can improve the overall performance and user trust of blockchain systems.
[0172] Figure 13 This is a block diagram of a data processing device based on blockchain, as shown in an exemplary embodiment of the present application. Figure 13 As shown, the device includes:
[0173] The computing contract execution module 1310 is configured to execute business transactions through computing contracts and obtain business transaction execution results. The computing contract is a smart contract used to process business logic calculations.
[0174] The storage contract execution module 1320 is configured to determine the storage allocation of the write-set data in the business transaction execution result through the storage contract execution, and obtain the storage method of the write-set data in the multi-dimensional heterogeneous storage system. The multi-dimensional heterogeneous storage system is composed of multiple storage media. The storage contract is a smart contract used to select a storage medium suitable for data storage according to a preset storage policy.
[0175] The data storage module 1330 is configured to store the write-set data in the multi-dimensional heterogeneous storage system according to the storage method corresponding to the write-set data.
[0176] In another exemplary embodiment, the apparatus further comprises:
[0177] The block generation module is configured to generate new blocks based on the business transaction execution results and the storage method corresponding to the write set data, and perform consensus processing on the new blocks;
[0178] The block storage module is configured to save the new block to the block ledger after the new block passes the consensus, and store the write set data in the multi-dimensional heterogeneous storage system according to the storage method corresponding to the write set data.
[0179] In another exemplary embodiment, the storage contract execution module 1320 includes:
[0180] A parsing unit configured to parse write-set data contained in a business transaction execution result;
[0181] a determination unit configured to determine a storage contract for performing storage allocation of write-set data;
[0182] The execution unit is configured to start a corresponding storage contract process from the storage contract process pool to execute storage allocation of the write-set data to obtain a storage method corresponding to the write-set data.
[0183] In another exemplary embodiment, the determining unit is further configured to:
[0184] Get the storage contract method bound to the computation contract;
[0185] A storage contract for executing storage allocation for write-set data is determined based on the storage contract method.
[0186] In another exemplary embodiment, the storage contract execution module 1320 further includes:
[0187] The default processing unit is configured to, when a storage contract for performing storage processing corresponding to the write-set data cannot be determined, perform storage allocation on the write-set data according to a default storage policy to obtain a storage method corresponding to the write-set data.
[0188] In another exemplary embodiment, the execution unit is further configured to:
[0189] Check whether the storage contract process pool contains the corresponding storage contract process;
[0190] If yes, start the queried storage contract process to perform storage allocation of write set data;
[0191] If not, if there are idle resources in the storage contract process pool, the corresponding storage contract process is started from the storage contract warehouse and added to the storage contract process pool, and the storage allocation of the write set data is performed through the started storage contract process.
[0192] In another exemplary embodiment, the storage contract execution module 1320 is further configured to:
[0193] The storage contract calls the interface of each storage medium according to its respective contracts to obtain the status information of various storage media;
[0194] Based on the status information of various storage media and the preset storage strategy, the storage allocation of the write-set data in the business transaction execution results is performed to obtain the storage method corresponding to the write-set data.
[0195] In another exemplary embodiment, the apparatus further includes a first verification module, wherein the first verification module is configured to:
[0196] Receive a business transaction processing request from the client, which contains the content information and signature information of the business transaction;
[0197] Perform client authentication based on the transaction content and signature information. After authentication is passed, proceed to client authority verification.
[0198] After passing the authority verification, the business transaction is stored in the transaction pool.
[0199] In another exemplary embodiment, the apparatus further comprises:
[0200] A system contract execution module is configured to execute a deployment transaction through a system contract and obtain a deployment transaction execution result. The system contract is a smart contract used to verify the contract code of the storage contract and the storage contract's permission to use various storage media in the multi-dimensional heterogeneous storage system;
[0201] The execution result processing module is configured to generate a new block based on the storage contract to be deployed in the deployment transaction and the deployment transaction execution result. After the new block passes the consensus, the new block is saved in the block ledger, and it is determined whether the deployment transaction execution result indicates that the deployment transaction is executed normally. If so, the storage contract is stored in the storage contract warehouse.
[0202] In another exemplary embodiment, the apparatus further includes a second verification module, and the second verification module is configured to:
[0203] Receive a deployment transaction processing request from the client, which contains the content and signature information of the storage contract to be deployed;
[0204] Perform client authentication based on the content and signature information of the storage contract to be deployed, and after passing the authentication, continue with the client's permission verification;
[0205] After passing the permission verification, the deployment transaction will be stored in the transaction pool.
[0206] In another exemplary embodiment, the system contract execution module is further configured to:
[0207] The system contract verifies the syntactic correctness and code executableness of the storage contract. Once the verification is passed, it continues to verify the usage permissions of the storage media that the storage contract may call;
[0208] After the usage authority is verified, a deployment transaction execution result is generated, indicating that the deployment transaction is executed normally.
[0209] In another exemplary embodiment, the apparatus further includes a consensus module, and the consensus module is configured to:
[0210] Send the new block to the blockchain slave node, so that the blockchain slave node starts the same system contract to process the deployment transaction contained in the new block, and judges whether the obtained deployment transaction execution result is consistent with the deployment transaction execution result of the blockchain master node, and broadcasts the judgment result;
[0211] Determine whether the new block passes the consensus based on the received judgment results.
[0212] It should be noted that the blockchain-based data processing device provided in the above embodiment and the blockchain-based data processing method provided in the above embodiment are based on the same concept. The specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here. In actual applications, the blockchain-based data processing device provided in the above embodiment can allocate the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.
[0213] An embodiment of the present application further provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs. When the one or more programs are executed by the one or more processors, the electronic device implements the blockchain-based data processing method provided in each of the above embodiments.
[0214] Figure 14 The following is a schematic diagram showing the structure of a computer system suitable for implementing an electronic device according to an embodiment of the present application. Figure 14 The computer system 1400 of the electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present application.
[0215] like Figure 14As shown, computer system 1400 includes a central processing unit (CPU) 1401, which can perform various appropriate actions and processes according to programs stored in read-only memory (ROM) 1402 or programs loaded from storage unit 1408 into random access memory (RAM) 1403, such as executing the methods described in the above embodiments. Various programs and data required for system operation are also stored in RAM 1403. CPU 1401, ROM 1402, and RAM 1403 are connected to each other via bus 1404. Input / output (I / O) interface 1405 is also connected to bus 1404.
[0216] The following components are connected to the I / O interface 1405: an input section 1406 including a keyboard, a mouse, and the like; an output section 1407 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and speakers; a storage section 1408 including a hard disk; and a communication section 1409 including a network interface card such as a LAN (Local Area Network) card or a modem. The communication section 1409 performs communication processing via a network such as the Internet. A drive 1410 is also connected to the I / O interface 1405 as needed. Removable media 1411, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 1410 as needed, so that computer programs read from the removable media can be installed in the storage section 1408 as needed.
[0217] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 1409, and / or installed from a removable medium 1411. When the computer program is executed by the central processing unit (CPU) 1401, the various functions defined in the system of the present application are executed.
[0218] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. The computer program contained in the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0219] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, program segment, or part of the code, and the above-mentioned module, program segment, or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0220] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. In some cases, the names of these units do not constitute limitations on the units themselves.
[0221] Another aspect of the present application provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program implements the aforementioned blockchain-based data processing method. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist independently and not be incorporated into the electronic device.
[0222] Another aspect of the present application provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the blockchain-based data processing method provided in each of the above embodiments.
[0223] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. Ordinary technicians in this field can easily make corresponding changes or modifications based on the main ideas and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.
[0224] It is understandable that in the specific implementation of this application, data related to computing contracts, storage contracts, business transactions, deployment transactions, etc. is involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
Claims
1. A data processing method based on blockchain, characterized in that: The method comprises: Executing business transactions through computing contracts to obtain business transaction execution results. The computing contracts are smart contracts used to process business logic calculations. Executing, by means of a storage contract, storage allocation of the write-set data in the business transaction execution result to obtain a storage method for the write-set data in a multi-dimensional heterogeneous storage system, wherein the multi-dimensional heterogeneous storage system is composed of multiple storage media, and the storage contract is a smart contract for selecting a storage medium suitable for data storage according to a preset storage policy; The write-set data is stored in the multi-dimensional heterogeneous storage system according to a storage method corresponding to the write-set data.
2. The method according to claim 1, characterized in that The method further comprises: Generate a new block based on the business transaction execution result and the storage method corresponding to the write-set data, and perform consensus processing on the new block; After the new block passes the consensus, the new block is saved in the block ledger, and the write set data is stored in the multi-dimensional heterogeneous storage system according to the storage method corresponding to the write set data.
3. The method according to claim 1 or 2, characterized in that The step of executing the storage allocation of the write-set data in the business transaction execution result through the storage contract to obtain the storage mode corresponding to the write-set data includes: Parsing the write-set data contained in the business transaction execution result; determining a storage contract for performing storage allocation for the writeset data; Start the corresponding storage contract process from the storage contract process pool to execute the storage allocation of the write set data to obtain the storage mode corresponding to the write set data.
4. The method according to claim 3, characterized in that Determining a storage contract for performing storage allocation of the write-set data includes: Obtaining a storage contract method bound to the computation contract; A storage contract for executing storage allocation for the write-set data is determined according to the storage contract method.
5. The method according to claim 3, characterized in that The method further comprises: If a storage contract for performing storage processing corresponding to the write-set data cannot be determined, storage allocation is performed on the write-set data according to a default storage policy to obtain a storage method corresponding to the write-set data.
6. The method according to claim 3, characterized in that The starting of a corresponding storage contract process from the storage contract process pool to execute storage allocation of the write-set data to obtain a storage mode corresponding to the write-set data includes: Query whether the storage contract process pool contains the corresponding storage contract process; If yes, start the queried storage contract process to execute the storage allocation of the write set data; If not, if there are idle resources in the storage contract process pool, the corresponding storage contract process is started from the storage contract warehouse and added to the storage contract process pool, and the storage allocation of the write set data is executed through the started storage contract process.
7. The method according to claim 1 or 2, characterized in that The step of executing the storage allocation of the write set in the business transaction execution result through the storage contract to obtain the storage mode corresponding to the write set includes: The storage contract obtains status information of various storage media according to the respective contract call interfaces of the multiple storage media; According to the status information of various storage media and the preset storage strategy, storage allocation of the write-set data in the business transaction execution result is performed to obtain a storage method corresponding to the write-set data.
8. The method according to claim 1 or 2, characterized in that Before executing the business transaction by computing the contract and obtaining the business transaction execution result, the method further includes: Receiving a business transaction processing request from a client, wherein the business transaction processing request includes content information and signature information of the business transaction; Performing identity verification of the client based on the content information and signature information of the business transaction, and continuing to verify the authority of the client after passing the identity verification; After passing the authority verification, the business transaction is stored in the transaction pool.
9. The method according to claim 1 or 2, characterized in that The method further comprises: Executing a deployment transaction through a system contract to obtain a deployment transaction execution result, wherein the system contract is a smart contract used to verify the contract code of the storage contract and the storage contract's permission to use various storage media in the multi-dimensional heterogeneous storage system; Generate a new block based on the storage contract to be deployed in the deployment transaction and the execution result of the deployment transaction. After the new block passes consensus, save the new block on the block ledger, and determine whether the execution result of the deployment transaction indicates that the deployment transaction is executed normally. If yes, the storage contract is stored in the storage contract warehouse.
10. The method according to claim 9, characterized in that Before executing the deployment transaction through the system contract and obtaining the deployment transaction execution result, the method further includes: Receive a deployment transaction processing request from the client, wherein the deployment transaction processing request contains the content information and signature information of the storage contract to be deployed; Perform identity verification of the client based on the content information and signature information of the storage contract to be deployed, and after passing the identity verification, continue to verify the client's permissions; After passing the authority verification, the deployment transaction is stored in the transaction pool.
11. The method according to claim 9, characterized in that The execution of the deployment transaction through the system contract to obtain the deployment transaction execution result includes: The system contract verifies the syntax correctness and code executableness of the storage contract, and after passing the verification, continues to verify the usage rights of the storage media that may be called by the storage contract; After the usage authority passes verification, a deployment transaction execution result is generated, indicating that the deployment transaction is executed normally.
12. The method according to claim 9, characterized in that The method is executed by a blockchain master node; the method further includes: Send the new block to the blockchain slave node, so that the blockchain slave node starts the same system contract to process the deployment transaction contained in the new block, and determines whether the obtained deployment transaction execution result is consistent with the deployment transaction execution result of the blockchain master node, and broadcasts the obtained determination result; Determine whether the new block passes the consensus based on the received judgment result.
13. A data processing device based on blockchain, characterized in that: The device comprises: A computing contract execution module, configured to execute a business transaction through a computing contract and obtain a business transaction execution result, wherein the computing contract is a smart contract for processing business logic calculations; a storage contract execution module configured to execute storage allocation of write-set data in the business transaction execution result through a storage contract to obtain a storage method for the write-set data in a multi-dimensional heterogeneous storage system, wherein the multi-dimensional heterogeneous storage system is composed of multiple storage media, and the storage contract is a smart contract for selecting a storage medium suitable for data storage according to a preset storage policy; The data storage module is configured to store the write-set data in the multi-dimensional heterogeneous storage system according to a storage method corresponding to the write-set data.
14. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to implement the blockchain-based data processing method according to any one of claims 1 to 12.
15. A computer-readable storage medium, characterized in that Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the blockchain-based data processing method according to any one of claims 1 to 12.
16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the blockchain-based data processing method according to any one of claims 1 to 12 is implemented.