Method, device, electronic device and computer storage medium for creating a business subchain

By creating business sub-chains in the blockchain, obtaining the parent blockchain of multiple business contracts and forming sub-blocks, the problem of low execution efficiency in the existing technology is solved, and the business scalability and scalability of the blockchain are realized. Improvement of data focusing efficiency.

CN115150092BActive Publication Date: 2024-09-06NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202210562824.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-23
Publication Date
2024-09-06
Estimated Expiration
2042-05-23

AI Technical Summary

Technical Problem

Existing blockchains lead to low execution efficiency when business contracts are aggregated, and cannot meet the needs for rapid focus and migration of different business data.

Method used

By obtaining the parent blockchain that stores multiple business contracts, the business data is obtained from each parent block, and sub-blocks are created based on the target business contract to form a business sub-chain, and data consistency is ensured through node consensus.

Benefits of technology

It improves the business scalability and data focusing efficiency of the blockchain, and enables the rapid creation and management of different business sub-chains.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115150092B
    Figure CN115150092B
Patent Text Reader

Abstract

This application discloses a method, apparatus, electronic device, and computer storage medium for creating a business subchain. The method for creating the business subchain includes: acquiring a parent blockchain storing data generated based on at least two business contracts, wherein the at least two business contracts include a target business for the business subchain to be created; acquiring business data stored in each parent block of the parent blockchain; obtaining target business data corresponding to the target business contract from the business data stored in each parent block; and creating a subblock corresponding to each parent block based on the target business data in each parent block, thereby obtaining the business subchain of the target business.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and specifically to a method, device, electronic device and computer storage medium for creating a business sub-chain. Background Art

[0002] Blockchain is a new application system based on computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. It is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. In a narrow sense, blockchain is a chain data structure that combines data blocks in a sequential manner in chronological order, and a distributed ledger that is cryptographically guaranteed to be tamper-proof and unforgeable. In a broad sense, blockchain technology is a new distributed infrastructure and computing method that uses block chain data structures to verify and store data, uses distributed node consensus algorithms to generate and update data, uses cryptography to ensure the security of data transmission and access, and uses smart contracts composed of automated script codes to program and operate data.

[0003] In existing blockchains, business data is often aggregated and stored in the MPT tree based on business contracts of different businesses, thereby ensuring that the business data is not tampered with. However, this blockchain design method will lead to low blockchain execution efficiency, and cannot meet the rapid focus of different business data, nor can it achieve rapid data migration.

[0004] Therefore, how to solve the above technical problems has become a technical problem that technical personnel in this field need to solve urgently. Summary of the invention

[0005] The present application provides a method, device, electronic device and computer storage medium for creating a business sub-chain to solve the problems existing in the prior art.

[0006] The method for creating the business subchain includes:

[0007] Obtaining a parent blockchain storing at least two business contracts generated based on the at least two business contracts, wherein the at least two business contracts include a target business of the business subchain to be created;

[0008] Obtaining the business data stored in each parent block of the parent blockchain respectively;

[0009] Obtaining target business data corresponding to the target business contract from the business data stored in each parent block;

[0010] According to the target business data in each parent block, a child block corresponding to each parent block is created, and a business sub-chain of the target business is obtained.

[0011] Optionally, the acquiring, from each parent block of the parent blockchain, the business data stored in each parent block includes:

[0012] Obtain the transaction lists stored in each parent block from each parent block of the parent blockchain respectively.

[0013] Optionally, obtaining target business data corresponding to the target business from the business data stored in each parent block includes:

[0014] Determine a business contract corresponding to each business, and classify the business data based on the business contract corresponding to each business;

[0015] Based on the classification result of the business data, the target business data corresponding to the target business in each parent block is obtained.

[0016] Optionally, creating, according to the target business data, each sub-block of the business sub-chain corresponding to each parent block, includes:

[0017] Sending the target business data in the first parent block of the parent blockchain and the business data in the first parent block to each node applying the parent blockchain;

[0018] Obtaining, through each of the nodes, a business data processing order in which each of the business contracts of the first parent block processes the business data, and processing the target business data according to the business processing order based on the target business contract code of the target business, to obtain a processing result of the target business data by each of the nodes;

[0019] Determine whether the processing results of the target business data by each node satisfy the node consensus. If the node consensus is satisfied, use the target business data as the business data in the first sub-block of the business sub-chain corresponding to the first parent block.

[0020] Optionally, the processing of the target business data according to the business processing order based on the target business contract code of the target business to obtain the processing result of the target business data by each node includes:

[0021] Determining a calling relationship between the target business contract and other business contracts in a process of generating the business data stored in the first parent block, wherein the business data stored in the first parent block is generated based on the business contracts of each business;

[0022] A hook function is added to the target business contract code to preferentially execute the calling operation of the target business contract and other business contracts, and the business contract code to which the hook function is added is run to process the first target business data in sequence.

[0023] Optionally, creating the business sub-chain according to the target business data in the adjacent sub-blocks includes:

[0024] Acquire a hash value of a first subblock in the adjacent subblocks, wherein the hash value of the first subblock is generated according to target service data of the first subblock and a block state of the first subblock;

[0025] Generate a hash value of a second subblock in the adjacent subblocks according to target business data of the second subblock and a block state of the second subblock, wherein the first subblock is located before the second subblock;

[0026] By using the hash value of the first sub-block, the target business data of the second sub-block and the second sub-block state as the block content of the second sub-block, a block connection between the adjacent first sub-block and the second sub-block is established.

[0027] Optionally, the method further includes: recording business data changes of each business through a business sub-chain corresponding to each business in the at least two business contracts, and generating a new sub-block corresponding to each business sub-chain according to the business data changes of each business.

[0028] Optionally, the method further includes:

[0029] Obtain the business data recorded in the new sub-blocks of each business sub-chain respectively;

[0030] Generate hash values ​​for each new sub-block based on the business data recorded in the new sub-blocks of each business sub-chain;

[0031] Based on the hash values ​​of the new child blocks, a new parent block of the parent blockchain is generated.

[0032] The present application also provides a device for creating a business subchain, including:

[0033] A first acquisition unit is used to acquire a parent blockchain generated based on at least two business contracts, wherein the at least two business contracts include a target business of the business subchain to be created;

[0034] A second acquisition unit is used to acquire the business data stored in each parent block of the parent blockchain from each parent block of the parent blockchain;

[0035] A data partitioning unit, used to obtain target business data corresponding to the target business contract from the business data stored in each parent block;

[0036] The sub-chain creation unit is used to create sub-blocks corresponding to each parent block according to the target business data in each parent block, and obtain the business sub-chain of the target business.

[0037] Optionally, the acquiring, from each parent block of the parent blockchain, the business data stored in each parent block includes:

[0038] Obtain the transaction lists stored in each parent block from each parent block of the parent blockchain respectively.

[0039] Optionally, obtaining target business data corresponding to the target business from the business data stored in each parent block includes:

[0040] Determine a business contract corresponding to each business, and classify the business data based on the business contract corresponding to each business;

[0041] Based on the classification result of the business data, the target business data corresponding to the target business in each parent block is obtained.

[0042] Optionally, creating, according to the target business data, each sub-block of the business sub-chain corresponding to each parent block, includes:

[0043] Sending the target business data in the first parent block of the parent blockchain and the business data in the first parent block to each node applying the parent blockchain;

[0044] Obtaining, through each of the nodes, a business data processing order in which each of the business contracts of the first parent block processes the business data, and processing the target business data according to the business processing order based on the target business contract code of the target business, to obtain a processing result of the target business data by each of the nodes;

[0045] Determine whether the processing results of the target business data by each node satisfy the node consensus. If the node consensus is satisfied, use the target business data as the business data in the first sub-block of the business sub-chain corresponding to the first parent block.

[0046] Optionally, the processing of the target business data according to the business processing order based on the target business contract code of the target business to obtain the processing result of the target business data by each node includes:

[0047] Determining a calling relationship between the target business contract and other business contracts in a process of generating the business data stored in the first parent block, wherein the business data stored in the first parent block is generated based on the business contracts of each business;

[0048] A hook function is added to the target business contract code to preferentially execute the calling operation of the target business contract and other business contracts, and the business contract code to which the hook function is added is run to process the first target business data in sequence.

[0049] Optionally, creating the business sub-chain according to the target business data in the adjacent sub-blocks includes:

[0050] Acquire a hash value of a first subblock in the adjacent subblocks, wherein the hash value of the first subblock is generated according to target service data of the first subblock and a block state of the first subblock;

[0051] Generate a hash value of a second subblock in the adjacent subblocks according to target business data of the second subblock and a block state of the second subblock, wherein the first subblock is located before the second subblock;

[0052] By using the hash value of the first sub-block, the target business data of the second sub-block and the second sub-block state as the block content of the second sub-block, a block connection between the adjacent first sub-block and the second sub-block is established.

[0053] Optionally, the device is also used to: record business data changes of each business through the business sub-chain corresponding to each business in the at least two business contracts, and generate a new sub-block corresponding to each business sub-chain according to the business data changes of each business.

[0054] Optionally, the device is further used to: respectively obtain the business data recorded in the new sub-block of each business sub-chain;

[0055] Generate hash values ​​for each new sub-block based on the business data recorded in the new sub-blocks of each business sub-chain;

[0056] Based on the hash values ​​of the new child blocks, a new parent block of the parent blockchain is generated.

[0057] The present application also provides an electronic device, including:

[0058] processor;

[0059] A memory is used to store a method program, and when the program is read and executed by the processor, the method for creating the above-mentioned business sub-chain is executed.

[0060] The present application also provides a computer storage medium, which stores a computer program, and when the program is executed, the method for creating the above-mentioned business sub-chain is implemented.

[0061] Compared with the prior art, this application has the following advantages:

[0062] The method for creating a business sub-chain provided in the present application includes: obtaining a parent blockchain that stores at least two business contracts generated based on the parent blockchain, wherein the at least two business contracts include the target business of the business sub-chain to be created; respectively obtaining the business data stored in each parent block of the parent blockchain; obtaining the target business data corresponding to the target business contract from the business data stored in each parent block; creating a child block corresponding to each parent block according to the target business data in each parent block, and obtaining the business sub-chain of the target business.

[0063] This method proposes a method for creating business sub-chains corresponding to different businesses based on the business data of the parent blockchain. This method obtains the business data corresponding to different businesses in each parent block of the parent blockchain, and completes the creation of the business sub-chain based on the business data. This method improves the business scalability of the blockchain parent chain and the data focus efficiency on different business sub-chains. BRIEF DESCRIPTION OF THE DRAWINGS

[0064] Figure 1 A flow chart of a method for creating a business subchain provided in an embodiment of the present application;

[0065] Figure 2 A schematic diagram of the structure of a blockchain provided in another embodiment of the present application;

[0066] Figure 3 A schematic diagram of the architecture of a blockchain provided in another embodiment of the present application;

[0067] Figure 4 A schematic diagram of generating a new block in a parent blockchain based on a child blockchain provided by another embodiment of the present application;

[0068] Figure 5 A schematic diagram of a device for generating a service sub-chain provided in another embodiment of the present application;

[0069] Figure 6 A schematic diagram of the structure of an electronic device provided in another embodiment of the present application. DETAILED DESCRIPTION

[0070] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application. Therefore, the present application is not limited to the specific embodiments disclosed below.

[0071] The terms used in this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The descriptions used in this application and the appended claims, such as "a", "first", and "second", are not limitations on quantity or sequence, but are used to distinguish the same type of information from each other.

[0072] The embodiment of the present application first provides a method for creating a business sub-chain. The implementation subject of the method can be various types of user terminals such as laptops, tablet computers, desktop computers, set-top boxes, mobile devices (for example, mobile phones, portable music players, personal digital assistants, dedicated messaging devices, game consoles), or a combination of any two or more of these data processing devices, or a server.

[0073] Please refer to Figure 1 , Figure 1 A flow chart of a method for creating a business subchain provided in an embodiment of the present application, the method comprising the following steps S101 to S103.

[0074] Step S101, obtaining a parent blockchain that stores data generated based on at least two business contracts, wherein the at least two business contracts include a target business of a business sub-chain to be created.

[0075] The parent blockchain can be understood as the main blockchain generated by smart contracts that contain multiple businesses. For example, the parent blockchain can be understood as a blockchain used to store the cash flow data between enterprise A and enterprise B and the contract data signed between the two enterprises, wherein the cash flow data stored in the parent blockchain is data generated by smart contract 1, and the contract data is data generated by smart contract 2.

[0076] The business contract is a smart contract, which is an electronic agreement that can automatically execute tasks that need to be completed manually, for example, a contract that can automatically calculate the amount of payment on behalf of the contracting parties and arrange the payment of the shielded amount. Smart contracts ensure the "decentralized characteristics" of blockchain, allowing both parties to the transaction to perform traceable, irreversible and secure transactions without the need for a third party to be impartial.

[0077] Specifically, the smart contract can be understood as a digital contract in life, a technology that automatically executes the content of the contract by the program when certain conditions are met. For example, user A and user B make an agreement with reward and punishment measures, and then enter the above agreement into the blockchain in the form of code. Once the conditions stipulated in the agreement are met, the corresponding reward and punishment measures will be automatically executed by the program.

[0078] Step S102, respectively obtain the business data stored in each parent block of the parent blockchain.

[0079] In practical applications, each block of the blockchain stores a series of business data. Specifically, in the embodiment of the present application, the business data may refer to a transaction list. Figure 2 , Figure 2 A schematic diagram of the structure of a blockchain provided in another embodiment of the present application.

[0080] like Figure 2 As shown, Figure 2 It includes: blockchain 201, the first block 201-1 (Genesis, ancestor block) of the blockchain, the second block 201-2, and the third block 201-3.

[0081] Specifically, the second block 201 - 2 stores the transaction list 2, the hash value of the second block 201 - 2 , and the hash value of the previous block of the second block 201 - 2 (ie, the hash value of the first block 201 - 1 ).

[0082] Among them, the hash value of the second block 201-2 can be understood as the fingerprint of the second block 201-2. The hash value is obtained based on the transaction list 2 stored in the second block. Furthermore, the hash value of the first block 201-1 is obtained based on the transaction list stored in the first block.

[0083] Similar to the above-mentioned second block 201-2, the third block 201-3 includes: transaction list 3 stored in the third block 201-3, the hash value of the third block 201-3, and the hash value of the previous block of the third block 201-3 (ie, the hash value of the second block 201-1).

[0084] Furthermore, since the first block 201 - 1 does not have a block before the first block 201 - 1 , the first block 201 - 1 only stores the transaction list 1 and the hash value of the first block 201 - 1 .

[0085] Furthermore, step S102 of the present application is to extract the transaction list stored therein from each block of the parent blockchain. Figure 2For example, assuming that blockchain 201 is the parent blockchain, the above step S102 can be understood as obtaining the transaction list 1 from the first block 201-1; obtaining the transaction list 2 from the second block 201-2; and obtaining the transaction list 3 from the third block.

[0086] Furthermore, the reason why the present application needs to obtain transaction data from each blockchain of the parent blockchain is to construct a child block corresponding to each business corresponding to each parent block. In order to achieve the purpose of constructing a child block corresponding to each business, the following step S103 is further performed.

[0087] Step S103: Obtain target business data corresponding to the target business contract from the business data stored in each parent block.

[0088] In the embodiment of the present application, the business contract dimension can be understood as the type of smart contract involved in the parent blockchain, and the data involved in the smart contracts of the same business are divided into the same category.

[0089] Specifically, the above step S103 includes:

[0090] Step S1, determining the business contracts corresponding to each business, and classifying the business data based on the business contracts corresponding to each business;

[0091] Step S2: based on the classification result of the business data, obtaining the target business data corresponding to the target business in each parent block.

[0092] For example, assuming that the parent blockchain is a blockchain used to simultaneously store the cash flow data between enterprise A and enterprise B and the aforementioned contract data between the two enterprises, and the business contracts executed when the cash flow data and the contract data are generated in the parent blockchain are different, the two can be classified according to the contract coding language of the business contract or the data storage method of the cash flow data and the contract data. For example, the coding language used in the business contract can be Solidity or Serpent or LLL, etc.; for another example, the storage method of the different business data can be tree structure storage or table structure storage, etc.

[0093] It is understandable that the classification standards and classification scenarios used in the above classification process are only for the purpose of facilitating the understanding of the classification process, and are not used to limit the classification scenarios and classification standards. Specifically, the above classification process of the business data in the contract dimension can be implemented in actual situations. For example, classification can be performed based on data call interfaces of different business data or data call methods of different data. This application does not impose any restrictions on this.

[0094] In an embodiment of the present application, the purpose of obtaining the target business data corresponding to the target contract in each parent block is to determine the business data to be stored in each sub-block in the business sub-chain to be created, wherein each sub-block of the business sub-chain corresponds to each parent block in the parent blockchain.

[0095] After obtaining the target business data, it is also necessary to reach a consensus on the target business data at each network node corresponding to the parent blockchain.

[0096] The node refers to a server in a region. In the Internet field, if all the running data of an enterprise is in the same server, then the server is a node. In layman's terms, since blockchain is essentially a decentralized distributed database, it does not rely on any centralized server, but is composed of many "small servers". In actual applications, as long as a blockchain application is downloaded through a mobile phone or computer, the mobile phone or computer that has downloaded the application will become a member of the "small server" and become a node, and participate in the data storage of the blockchain and ensure the accuracy of the data stored in the blockchain.

[0097] Here we still take the above-mentioned company A and company B as an example. It is assumed that employee a in company A is responsible for managing the cash flow between the company and company B, employee b in company A is responsible for managing the contract between the company and company B, and the parent blockchain is managed through the office computers of employee a and employee b respectively. Employee c in company B with similar thresholds is responsible for managing the cash flow between the company and company A, employee d in company B is responsible for managing the contract between the company and company B, and the parent blockchain is managed through the office computers of employee c and employee d respectively, then the nodes are the computers of employees a, b, c, and d.

[0098] The consensus, i.e., the consensus mechanism of the blockchain, in the field of blockchain technology, since the blockchain adopts a decentralized design, the nodes are scattered and parallel everywhere, therefore, a system must be designed to maintain the operating order and fairness of the system, unify the version of the blockchain, and reward users who provide resources to maintain the block, and punish malicious harm. In the embodiment of the present application, the main function of the consensus mechanism is to unify the version of the blockchain, that is, to ensure that the business data of each sub-block of the business sub-chain to be created is recognized by all nodes.

[0099] Furthermore, in order to ensure that the business data of each sub-block of the business sub-chain to be created is recognized by all nodes, the method for creating a business sub-chain provided in the embodiment of the present application further includes the following steps S3 to S5:

[0100] Step S3, sending the target business data in the first parent block of the parent blockchain and the business data in the first parent block to each node applying the parent blockchain;

[0101] Step S4, obtaining, through each node, a business processing order of each business contract of the first parent block for processing the business data, and processing the target business data according to the business processing order based on the target business contract code of the target business, to obtain a processing result of each node on the target business data;

[0102] Step S5, determining whether the processing results of the target business data by each node satisfy the node consensus. If the node consensus is satisfied, the target business data is used as the business data in the first sub-block of the business sub-chain corresponding to the first parent block.

[0103] Among them, the first parent block in the parent blockchain can be any block in the parent blockchain, and this application does not impose any restrictions on this.

[0104] Furthermore, the reason why the present application sends the target business data and the full amount of business in the parent block to each node is to enable each node in the entire network to execute the target business contract, process the target business data in the order of processing the business data in the parent block, and obtain the processing result for the target business data.

[0105] Furthermore, in the process of actual application, in the process of deploying the parent block contract, the calling dependency relationship between different business contracts needs to be considered. Therefore, in the process of executing the target business through the target business contract, there are business contracts that need to call other businesses. The business contracts are processed in the order of processing the business data through other contracts first, and the processing results of other business contracts are obtained. Then, the target business data is executed through the target business contract.

[0106] For example, still taking the parent blockchain of Company A and Company B as an example, suppose a section of flow data between Company A and Company B can only be generated after a contract takes effect and is written into the parent blockchain. In this case, if a sub-chain corresponding to the flow business is established, then according to the processing order of the business data, the contract code corresponding to the contract data should be executed first, and the state data of the contract taking effect should be written into the blockchain before the contract code corresponding to the flow business can be executed. In the actual application process, a business contract can declare a state variable of address type that can be publicly accessed through the code "addresspublic minte", where the address type is a 160-bit value and no arithmetic operations are allowed. The keyword public in the code automatically generates a function that allows access to the current value of the state variable of address type outside the business contract. For example, assuming that the data (state variables) of the second business contract are needed in the process of running the target business contract code to process the first target business data, the query Value() interface of the second business contract address2 can be called to query the current value of the state variable of address2, so that the target business contract code can continue to process the target business data in the processing order of the business data and obtain the processing result of the target business data.

[0107] Specifically, in order to ensure accurate calling between the business contracts, a hook function can be imported into the business contract code so that the target business contract waits for the completion of calling of other contracts that have a dependent relationship with the target business contract before continuing to execute.

[0108] The hook function refers to the process of modifying several instructions in the header of a function to make it jump to a custom function (generally called a custom hook function) when the target process executes a certain function (when the function needs to be hooked, the function is called the hooked function). This is called function hook. Sometimes, when the logic of the hooked function is more complicated, it is necessary to implement the function of the original function in the custom hook function. At this time, the hook framework will provide a function pointer, and calling the function pointer can complete the original function of the hooked function.

[0109] After the target business contract code is executed, the processing results of the target business contract obtained by each node in the entire network are obtained, and it is determined whether the same rate between the processing results of each node reaches a preset threshold. If the same rate between the processing results of each node reaches the preset threshold, it is determined that the nodes in the entire network have reached a consensus. In this case, the business data in the sub-blockchain of the target business can be

[0110] In an optional implementation of the present application, the preset threshold of the same rate of processing results of each node can be set to 51%, that is, if more than half of the nodes obtain the same processing results, it is considered that a consensus of the entire network has been reached. It should be noted that the preset threshold of the same rate can be set according to actual conditions, and this application does not impose any restrictions on this.

[0111] Furthermore, in the actual application process, the execution result of the target business contract will be saved in the form of a key-value pair with (address + subchain block height) as the key and the contract result as the value.

[0112] Step S104, creating each child block corresponding to each parent block according to the target business data in each parent block, and obtaining the business sub-chain of the target business.

[0113] In the embodiment of the present application, creating a child block corresponding to each parent block according to the target service data in the parent block includes:

[0114] Obtaining a processing result of the target business contract on the target business data in the first parent block;

[0115] Generate a hash value corresponding to the first sub-block according to the processing result of the target business data and the business data in the first sub-block;

[0116] The first sub-block is obtained by taking the processing result of the target data, the hash value of the first sub-block, the business data in the first sub-block, and the hash value of the previous sub-block of the first sub-block as the content stored in the first sub-block.

[0117] That is to say, assuming that the business sub-chain of the target business includes: sub-block 1, sub-block 2, and sub-block 3, then the sub-block 1 includes: the target business data 1 in the first parent block in the parent blockchain, the hash value generated according to the target business data 1, and the processing result of executing the target business contract to process the target business data; the sub-block 2 includes: the hash value of the sub-block 1, the target business data 2 in the second parent block in the parent blockchain, the hash value generated according to the target business data 2, and the processing result of executing the target business contract to process the target business data; the sub-block 3 includes: the hash value of the sub-block 2, the target business data 3 in the third parent block in the parent blockchain, the hash value generated according to the target business data 3, and the processing result of executing the target business contract to process the target business data.

[0118] In order to facilitate the understanding of the present application, the embodiments of the present application are also combined with Figure 3 The process of creating sub-blocks corresponding to each business based on the parent blockchain is introduced, including: Figure 3 A schematic diagram of the architecture of a blockchain provided in accordance with another embodiment of the present application.

[0119] Figure 3 The parent blockchain 301 is included; the child blocks in the parent blockchain 301: parent block 301-1, parent block 301-2, parent block 301-3;

[0120] Business subchain 302, business subchain 303, business subchain 304; the business contract corresponding to business subchain 302 is business contract 1, the business contract corresponding to business subchain 303 is business contract 2, and the business contract corresponding to business subchain 304 is business contract 3;

[0121] The business subchain 302 includes: subblock 302-1, subblock 302-2, and subblock 302-3;

[0122] The business subchain 303 includes: subblock 303-1, subblock 303-2, and subblock 303-3;

[0123] The business subchain 304 includes: subblock 304-1, subblock 304-2, and subblock 304-3;

[0124] Here, the business subchain 302 is taken as the target business subchain, and the generation process of subblocks 302-1 to 302-3 in the business subchain 302 is described to facilitate understanding of the generation process of each business subchain.

[0125] The generation process of sub-block 302-1 is as follows:

[0126] First, the business data in the parent block 301-1 is divided into contract dimensions, and the business data corresponding to different business contracts are obtained according to the division results, and then the business data corresponding to business contract 1 in the parent block 301-1 is obtained. Here, the business data corresponding to business contract 1 in the parent block 201-1 is recorded as business data 1-1;

[0127] Secondly, the business data 1-1 and the full amount of business data in the parent block 201-1 are sent to the full network nodes of the parent blockchain 201.

[0128] Each node processes the business data 1-1 using the first business contract code according to the processing order of the full amount of business data based on the first target business contract, and obtains a corresponding processing result, and based on the processing result of each node, determines whether all network nodes have reached a node consensus on the business data 1-1;

[0129] Finally, when all nodes in the entire network reach a node consensus, the business data 1-1 is used as the business data recorded in the sub-block 302-1, and the hash value of the sub-block 302-1 is constructed based on the business data 1-1, so as to associate the sub-block 302-1 with subsequent blocks.

[0130] Furthermore, for the generation process of sub-block 302-2:

[0131] Similar to the generation process of the above-mentioned child block 302-1, first, the business data in the parent block 301-2 is divided by the contract dimension, and then the business data corresponding to the business contract 2 in the parent block 301-2 is obtained. Here, the business data corresponding to the business contract 2 in the parent block 301-2 is recorded as business data 1-2;

[0132] Secondly, similar to the above-mentioned node consensus process, the business data 1-2 and the full amount of business data in the parent block 301-2 are sent to all nodes in the network, and then it is determined whether all nodes in the network have reached a node consensus on the business data 1-2;

[0133] Finally, when all nodes in the entire network reach a node consensus, business data 1-2 is used as the business data recorded in sub-block 302-2, and the hash value of sub-block 302-2 is constructed based on business data 1-2, so that sub-block 302-1 can be associated with subsequent blocks; at the same time, the hash value of sub-block 302-1 is recorded in sub-block 302-2 to associate sub-block 302-1 with sub-block 302-2.

[0134] Furthermore, for the generation process of sub-block 302-3:

[0135] Similar to the generation process of the above sub-blocks 302-1 and 302-2, first, the business data in the parent block 301-3 is divided by the contract dimension, and then the business data corresponding to the business contract 3 in the parent block 201-3 is obtained, which is recorded as business data 1-3;

[0136] Secondly, similar to the above-mentioned node consensus process, the business data 1-3 and the full amount of business data in the parent block 301-3 are sent to all nodes in the network, and then it is determined whether all nodes in the network have reached a node consensus on the business data 1-3;

[0137] Finally, when all nodes in the entire network reach a node consensus, business data 1-3 is used as the business data recorded in sub-block 302-3, and the hash value of sub-block 302-3 is constructed based on business data 1-3, so that sub-block 302-3 can be associated with subsequent blocks; at the same time, the hash value of sub-block 302-2 is recorded in sub-block 302-3 to associate sub-block 302-2 with sub-block 302-3.

[0138] The above is provided in the embodiments of the present application. Figure 3 The generation process of each sub-block of the first business blockchain 302, the generation process of each sub-block of the second business blockchain 303 and the third business blockchain 304 is similar to the generation process of each sub-block of the first business blockchain 302, and will not be repeated here.

[0139] In an optional implementation of the present application, after generating business sub-chains for different businesses, the parent blockchain only needs to record the hash value of each sub-block in the business sub-chain of each business to monitor each business in the parent blockchain, and the original function of the parent blockchain to record and monitor business data can be completed through the business sub-chain corresponding to each business contract.

[0140] Furthermore, after each business sub-chain generates a new sub-block, the embodiment of the present application also includes a process of merging the newly generated sub-blocks of each business sub-chain into a new parent block of the parent blockchain:

[0141] Please refer to Figure 4 , Figure 4 A schematic diagram of generating a new block in a parent blockchain based on a child blockchain provided in another embodiment of the present application.

[0142] Figure 4 Included:

[0143] Parent blockchain 401; child blocks in parent blockchain 401: parent block 401-1, parent block 401-2, parent block 401-3, parent block 401-4. Parent block 401-1 and parent block 401-2 are the original child blocks in parent blockchain 401.

[0144] Business subchain 402, business subchain 403, business subchain 404; wherein, business subchain 402 includes: subblocks 402-1 and 402-2 generated based on the business data of parent blocks 401-1 and 401-2, and subblocks 402-3 and 402-4 newly generated after the business subchain 402 monitors the first business data;

[0145] Similar to the above-mentioned business subchain 402, the business subchain 403 includes: subblocks 403-1 and 403-2 generated based on the business data of the parent blocks 401-1 and 401-2, and subblocks 403-3 and 403-4 generated after the second business subblockchain monitors the first business data;

[0146] The business subchain 404 includes: subblocks 404-1 and 404-2 generated based on the business data of the parent blocks 401-1 and 401-2, and subblocks 404-3 and 404-4 generated after the business subchain 404 monitors the third business data;

[0147] Specifically, the process of generating child blocks based on the original parent blocks in the parent blockchain in the business sub-chain 402, business sub-chain 403 and business sub-chain 404 is the same as Figure 3 The process described in is similar to that described in Figure 3 The introduction of will not be repeated here.

[0148] Furthermore, taking the generation process of the parent block 401-3 as an example, the process of merging business sub-chains to generate a new parent block is explained.

[0149] like Figure 4 As shown, business subchain 402, business subchain 403 and business subchain 404 generate new subblocks, namely: subblock 402-3, subblock 403-3, subblock 403-4. Afterwards, based on the business data stored in the above subblocks, new hash values ​​are generated, namely hash value 1, hash value 2 and hash value 3, respectively. The hash values ​​1, hash value 2 and hash value 3 are provided to the parent blockchain 401, so that the parent blockchain 401 records the above hash values ​​as hash value sets to the new parent block 401-3.

[0150] Similar to the above-mentioned parent block 401-3, the parent block 401-4 is also generated based on a similar method as described above, which will not be repeated here.

[0151] To sum up, the method for creating a business sub-chain provided by the present application proposes a method for creating business sub-chains corresponding to different businesses based on the business data of the parent blockchain. The method divides the business data of the parent blockchain into contract dimensions, accurately obtains the business data corresponding to different businesses in each parent block of the parent blockchain, and completes the creation of the business sub-chain based on the business data. This method improves the business scalability of the blockchain parent chain and the data focus efficiency on different business sub-chains.

[0152] Another embodiment of the present application also provides a device for creating a business sub-chain. Please refer to Figure 5 , Figure 5 This is a schematic diagram of a device for generating a service sub-chain provided in another embodiment of the present application. Since the device embodiment is basically the same as the above method embodiment, the description is relatively simple. For relevant details, please refer to the partial description of the above method embodiment.

[0153] The device for creating the business subchain includes:

[0154] A first acquisition unit 501 is used to acquire a parent blockchain generated based on at least two business contracts, wherein the at least two business contracts include a target business of the business subchain to be created;

[0155] The second acquisition unit 502 is used to respectively acquire the business data stored in each parent block of the parent blockchain from each parent block of the parent blockchain;

[0156] The data partitioning unit 503 is used to partition the business data according to the business contract dimension, and obtain the target business data corresponding to the target business contract in each parent block based on the partition result;

[0157] The sub-chain creation unit 504 is used to create a sub-block corresponding to each parent block according to the target business data in each parent block, and obtain the business sub-chain of the target business.

[0158] Optionally, the acquiring, from each parent block of the parent blockchain, the business data stored in each parent block includes:

[0159] Obtain the transaction lists stored in each parent block from each parent block of the parent blockchain respectively.

[0160] Optionally, dividing the business data according to the business contract dimension, and obtaining target business data corresponding to the target business in each parent block based on the division result, includes:

[0161] Determine a business contract corresponding to each business, and classify the business data based on the business contract corresponding to each business;

[0162] Based on the classification result of the business data, the target business data corresponding to the target business in each parent block is obtained.

[0163] Optionally, creating, according to the target business data, each sub-block of the business sub-chain corresponding to each parent block, includes:

[0164] Sending the target business data in the first parent block of the parent blockchain and the business data in the first parent block to each node applying the parent blockchain;

[0165] Obtaining, through each of the nodes, a business data processing order in which each of the business contracts of the first parent block processes the business data, and processing the target business data according to the business processing order based on the target business contract code of the target business, to obtain a processing result of the target business data by each of the nodes;

[0166] Determine whether the processing results of the target business data by each node satisfy the node consensus. If the node consensus is satisfied, use the target business data as the business data in the first sub-block of the business sub-chain corresponding to the first parent block.

[0167] Optionally, the processing of the target business data according to the business processing order based on the target business contract code of the target business to obtain the processing result of the target business data by each node includes:

[0168] Determining a calling relationship between the target business contract and other business contracts in a process of generating the business data stored in the first parent block, wherein the business data stored in the first parent block is generated based on the business contracts of each business;

[0169] A hook function is added to the target business contract code to preferentially execute the calling operation of the target business contract and other business contracts, and the business contract code to which the hook function is added is run to process the first target business data in sequence.

[0170] Optionally, creating the business sub-chain according to the target business data in the adjacent sub-blocks includes:

[0171] Acquire a hash value of a first subblock in the adjacent subblocks, wherein the hash value of the first subblock is generated according to target service data of the first subblock and a block state of the first subblock;

[0172] Generate a hash value of a second subblock in the adjacent subblocks according to target business data of the second subblock and a block state of the second subblock, wherein the first subblock is located before the second subblock;

[0173] By using the hash value of the first sub-block, the target business data of the second sub-block and the second sub-block state as the block content of the second sub-block, a block connection between the adjacent first sub-block and the second sub-block is established.

[0174] Optionally, the device is also used to: record business data changes of each business through the business sub-chain corresponding to each business in the at least two business contracts, and generate a new sub-block corresponding to each business sub-chain according to the business data changes of each business.

[0175] Optionally, the device is also used for:

[0176] Obtain the business data recorded in the new sub-blocks of each business sub-chain respectively;

[0177] Generate hash values ​​for each new sub-block based on the business data recorded in the new sub-blocks of each business sub-chain;

[0178] Based on the hash values ​​of the new child blocks, a new parent block of the parent blockchain is generated.

[0179] Another embodiment of the present application also provides an electronic device, please refer to Figure 6 , Figure 6 A schematic diagram of the structure of an electronic device provided in another embodiment of the present application.

[0180] The electronic device includes:

[0181] At least one processor 601, at least one memory 603, at least one communication interface 602, and at least one communication bus 604;

[0182] Optionally, the communication interface 602 may be an interface of a communication module, such as an interface of a GSM module;

[0183] The processor 601 may be a CPU, or an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application;

[0184] The memory 603 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0185] Among them, the memory 603 is a program for storing methods, and when the program is read and executed by the processor, the method provided by the method embodiment of the present application is executed.

[0186] A sixth embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program, and when the program is executed, the method provided in the above method embodiment is implemented.

[0187] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.

[0188] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0189] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0190] 1. Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.

[0191] 2. Those skilled in the art should understand that the embodiments of the present application can be provided as a system or electronic device. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

Claims

1. A method for creating a business sub-chain. It is characterized in that include: Obtaining a parent blockchain storing at least two business contracts generated based on the at least two business contracts, wherein the at least two business contracts include a target business of the business subchain to be created; Obtaining the business data stored in each parent block of the parent blockchain respectively; Obtaining target business data corresponding to the target business contract from the business data stored in each parent block; According to the target business data in each parent block, create a child block corresponding to each parent block, and obtain the business subchain of the target business; The step of creating child blocks corresponding to the parent blocks according to the target service data in the parent blocks includes: Sending the target business data in the first parent block of the parent blockchain to each node applying the parent blockchain; Determine whether the processing results of the target business data by each node satisfy the node consensus. If the node consensus is satisfied, use the target business data as the business data in the first sub-block of the business sub-chain corresponding to the first parent block.

2. The method according to claim 1, It is characterized in that The obtaining, from each parent block of the parent blockchain, the business data stored in each parent block, includes: Obtain the transaction lists stored in each parent block from each parent block of the parent blockchain respectively.

3. The method according to claim 1, It is characterized in that Obtaining target business data corresponding to the target business from the business data stored in each parent block, including: Determine a business contract corresponding to each business, and classify the business data based on the business contract corresponding to each business; Based on the classification result of the business data, the target business data corresponding to the target business in each parent block is obtained.

4. The method according to claim 1, It is characterized in that The step of creating child blocks corresponding to the parent blocks according to the target service data in the parent blocks further includes: Sending the business data in the first parent block of the parent blockchain to each node applying the parent blockchain; Through each of the nodes, the business data processing order of each business contract of the first parent block to process the business data is obtained, and based on the target business contract code of the target business, the target business data is processed according to the business processing order to obtain the processing results of the target business data by each node.

5. The method according to claim 4, It is characterized in that The target business contract code based on the target business, processing the target business data according to the business processing sequence, and obtaining the processing result of the target business data by each node, includes: Determining a calling relationship between the target business contract and other business contracts in a process of generating the business data stored in the first parent block, wherein the business data stored in the first parent block is generated based on the business contracts of each business; A hook function is added to the target business contract code to preferentially execute the calling operation of the target business contract and other business contracts, and the business contract code with the hook function added is run to process the target business data in sequence.

6. The method according to claim 1, It is characterized in that According to the target business data in the adjacent sub-blocks, the business sub-chain is created, including: Acquire a hash value of a first subblock in the adjacent subblocks, wherein the hash value of the first subblock is generated according to target service data of the first subblock and a block state of the first subblock; Generate a hash value of a second subblock in the adjacent subblocks according to target business data of the second subblock and a block state of the second subblock, wherein the first subblock is located before the second subblock; By using the hash value of the first sub-block, the target business data of the second sub-block and the second sub-block state as the block content of the second sub-block, a block connection between the adjacent first sub-block and the second sub-block is established.

7. The method according to claim 1, It is characterized in that The method also includes: recording business data changes of each business through the business sub-chain corresponding to each business in the at least two business contracts, and generating new sub-blocks corresponding to each business sub-chain according to the business data changes of each business.

8. The method according to claim 7, It is characterized in that The method further comprises: Obtain the business data recorded in the new sub-blocks of each business sub-chain respectively; Generate hash values ​​for each new sub-block based on the business data recorded in the new sub-blocks of each business sub-chain; Based on the hash values ​​of the new child blocks, a new parent block of the parent blockchain is generated.

9. A device for creating a business sub-chain, It is characterized in that include: A first acquisition unit is used to acquire a parent blockchain generated based on at least two business contracts, wherein the at least two business contracts include a target business of the business subchain to be created; A second acquisition unit is used to acquire the business data stored in each parent block of the parent blockchain from each parent block of the parent blockchain; A data partitioning unit, configured to partition the business data according to the business contract dimension, and obtain target business data corresponding to the target business contract in each parent block based on the partitioning result; A subchain creation unit, used to create a subblock corresponding to each parent block according to the target business data in each parent block, and obtain a business subchain of the target business; The step of creating child blocks corresponding to the parent blocks according to the target business data in the parent blocks and obtaining the business subchain of the target business includes: Sending the target business data in the first parent block of the parent blockchain to each node applying the parent blockchain; Determine whether the processing results of the target business data by each node satisfy the node consensus. If the node consensus is satisfied, use the target business data as the business data in the first sub-block of the business sub-chain corresponding to the first parent block.

10. An electronic device, It is characterized in that include: processor; A memory for storing a method program, wherein when the program is read and executed by the processor, the method according to any one of claims 1 to 8 is executed.

11. A computer storage medium, It is characterized in that The computer storage medium stores a computer program, and when the program is executed, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Multi-blockchain network networking method, device and system

    CN109639550A

  • Data processing method, device and equipment based on block chain

    CN111708844A

  • Block chain fragmentation method and block chain network system

    CN114389878A

  • Method and system for certifying block-chain-based copyright event proxy

    WO2020052382A1

  • Methods and apparatus for generating state tree of block and validating on-chain data

    WO2021068728A1