Block chain transaction processing method and device, storage medium and computer equipment

By using blockchain transaction processing methods, block generating nodes distinguish between transactions in the first-layer and second-layer networks when generating blocks, updating only the world state of the first-layer network. This solves the inefficiency problem caused by the occupancy of the second-layer network and achieves more efficient blockchain transaction processing.

CN121284045APending Publication Date: 2026-01-06TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410914224.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2026-01-06

AI Technical Summary

Technical Problem

Because resource exchange events in the second-layer network occupy the world state of the first-layer network, the efficiency of blockchain transaction processing decreases, and existing technologies have failed to effectively solve this problem.

Method used

Using blockchain transaction processing methods, block generating nodes obtain resource processing transactions from the set of pending transactions for both the first-layer and second-layer networks, generate block bodies and temporarily store data, and update only the world state of the first-layer network after verification, thus avoiding duplicate packaging of data from the second-layer network.

Benefits of technology

Reducing the world state expansion by one layer of the network improves the efficiency of blockchain transaction processing and reduces the need for scaling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121284045A_ABST
    Figure CN121284045A_ABST
Patent Text Reader

Abstract

The invention provides a block chain transaction processing method and device, a storage medium and computer equipment. The method is applied to a layer of network nodes of a preset block chain network, and comprises the following steps: obtaining a plurality of to-be-processed first resource processing transactions and a plurality of to-be-processed second resource processing transactions from a to-be-processed resource processing transaction set, and generating a block body based on the plurality of to-be-processed first resource processing transactions; generating temporary storage data based on a plurality of to-be-processed second resource processing transactions; generating a first target block according to the block body and the temporary storage data, and sending the first target block to a consensus node in a layer of network for verification; and when it is determined that the first target block passes verification based on a verification result returned by the consensus node, broadcasting the first target block to each node in the first-layer network, and updating the world state of the first-layer network based on the block body. According to the method, the processing efficiency of the block chain transaction in the block chain network can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of blockchain technology, and in particular to a blockchain transaction processing method, apparatus, storage medium, and computer equipment. Background Technology

[0002] Blockchain is a decentralized distributed ledger that is stored in blocks, is immutable, secure and reliable. It combines distributed storage, peer-to-peer transmission, consensus mechanisms, cryptography and other technologies to record resource exchange events and information through a continuously growing chain of data blocks, ensuring data security and transparency.

[0003] Layer 2 networks are additional networks built on top of Layer 1 networks. They handle a large number of resource exchange events and smart contract calls, thereby improving the scalability and efficiency of the entire system. Layer 2 networks alleviate the load on Layer 1 by processing numerous resource exchange events outside of Layer 1 and then submitting the results in batches to Layer 1. Resource exchange events between nodes in the Layer 2 network are executed, compressed, packaged, and sent to nodes in the Layer 1 network by the ordering nodes in the Layer 2 network, and recorded in the world state of the Layer 1 network. However, since the storage resources for the world state are limited, as the Layer 2 network continuously writes data to the Layer 1 network, the world state of the Layer 1 network expands, leading to a decrease in the processing efficiency of blockchain transactions. Summary of the Invention

[0004] This disclosure provides a blockchain transaction processing method, apparatus, storage medium, and computer device, which can improve the processing efficiency of blockchain transactions.

[0005] According to one aspect of this disclosure, a blockchain transaction processing method is provided, the method being applied to a first-layer network node of a preset blockchain network, the preset blockchain network including a first-layer network and a second-layer network, wherein the first-layer network node is a node that generates blocks within the first-layer network, the method comprising:

[0006] Multiple first resource processing transactions and multiple second resource processing transactions to be processed are obtained from the set of pending resource processing transactions. The first resource processing transactions are resource processing transactions generated based on resource exchange events between nodes in the first-layer network, and the second resource processing transactions are resource processing transactions generated based on resource exchange events between nodes in the second-layer network.

[0007] A block body is generated based on the multiple pending first resource processing transactions;

[0008] Temporary storage data is generated based on the multiple pending second resource processing transactions;

[0009] A first target block is generated based on the block body and the temporary storage data, and the first target block is sent to the consensus node in the first layer network for verification;

[0010] When the first target block is determined to have passed verification based on the verification result returned by the consensus node, the first target block is broadcast to every node in the layer network, and the world state of the layer network is updated based on the block body.

[0011] According to one aspect of this disclosure, a blockchain transaction processing apparatus is provided. The apparatus is applied to a first-layer network node in a preset blockchain network, the preset blockchain network including a first-layer network and a second-layer network. The first-layer network node is a node that generates blocks within the first-layer network. The apparatus includes:

[0012] The acquisition unit is used to acquire multiple first resource processing transactions to be processed and multiple second resource processing transactions to be processed from the set of pending resource processing transactions. The first resource processing transactions are resource processing transactions generated based on resource exchange events between nodes in the first-layer network, and the second resource processing transactions are resource processing transactions generated based on resource exchange events between nodes in the second-layer network.

[0013] The first generation unit is used to generate a block body based on the plurality of pending first resource processing transactions;

[0014] The second generation unit is used to generate temporary storage data based on the plurality of pending second resource processing transactions;

[0015] The third generation unit is used to generate a first target block based on the block body and the temporary storage data, and send the first target block to the consensus node in the first layer network for verification;

[0016] The update unit is used to broadcast the first target block to each node in the first layer network when the first target block is determined to have passed verification based on the verification result returned by the consensus node, and to update the world state of the first layer network based on the block body.

[0017] Optionally, in some embodiments, the third generation unit includes:

[0018] A construction subunit is used to construct the block structure of the first target block, the block structure including a block header storage area, a block body storage area, and a temporary storage area;

[0019] A storage subunit is used to store the temporary storage data in the temporary storage area and the block body in the block body storage area;

[0020] The first generation subunit is used to generate block header data based on multiple pending first resource processing transactions in the block body, store the block header data in the block header storage area, and obtain the first target block;

[0021] The sending subunit is used to send the first target block to the consensus node in the layer network for verification.

[0022] Optionally, in some embodiments, the first generating subunit includes:

[0023] The first calculation module is used to calculate the hash value of each pending first resource processing transaction in the block body;

[0024] The second calculation module is used to calculate the Merkle root based on the hash value and store the Merkle root in the block header storage area.

[0025] Optionally, in some embodiments, after the update unit, the blockchain transaction processing apparatus provided in this disclosure further includes:

[0026] An adding unit is used to add the first target block to the target blockchain;

[0027] A determining unit is used to determine, in the target blockchain, a block of temporary storage data to be deleted that needs to be processed.

[0028] The deletion unit is used to delete the temporary storage data stored in the block to be processed.

[0029] Optionally, in some embodiments, the determining unit includes:

[0030] The first acquisition subunit is used to acquire the first timestamp of each block in the target blockchain;

[0031] The first determining subunit is used to determine the pending block of temporary storage data to be deleted based on the time difference between the first timestamp and the second timestamp of the first target block.

[0032] Optionally, in some embodiments, the determining unit further includes:

[0033] The second acquisition subunit is used to acquire the first block height value of each block in the target blockchain;

[0034] The second determining subunit is used to determine the block to be processed for the temporary storage data to be deleted based on the block height difference between the first block height value and the second block height value of the first target block.

[0035] Optionally, in some embodiments, the first generating unit includes:

[0036] The first sorting subunit is used to sort the plurality of pending first resource processing transactions according to the first resource unit consumption of each pending first resource processing transaction to obtain a first resource processing transaction sequence.

[0037] The calculation subunit is used to calculate the first resource consumption corresponding to each first resource processing transaction based on the first resource unit consumption.

[0038] The third determining subunit is used to determine the first target resource processing transaction in the first resource processing transaction sequence based on the first preset total resource amount corresponding to the first target block and the first resource consumption amount.

[0039] The second generation subunit is used to generate a block body based on the transaction processing of the first target resource.

[0040] Optionally, in some embodiments, the third determining subunit includes:

[0041] The accumulation module is used to accumulate the corresponding first resource consumption based on the sorting order of the first resource processing transactions in the first resource processing transaction sequence to obtain the cumulative value of resource consumption.

[0042] The determination module is used to determine the first resource processing transaction that is ranked before the critical resource processing transaction corresponding to the cumulative resource consumption value as the first target resource processing transaction when the cumulative resource consumption value is greater than the first preset total resource amount.

[0043] Optionally, in some embodiments, the second generating unit includes:

[0044] The second sorting subunit is used to sort the plurality of pending second resource processing transactions according to the second resource consumption corresponding to each pending second resource processing transaction, so as to obtain a second resource processing transaction sequence.

[0045] The fourth determining subunit is used to determine the second target resource processing transaction in the second resource processing transaction sequence based on the second preset total resource amount of the first target block and the second resource consumption amount;

[0046] The third generation subunit is used to generate the temporary storage data based on the second target resource processing transaction.

[0047] Optionally, in some embodiments, the calculation process for the second resource consumption of each of the second resource processing transactions to be processed specifically includes the following steps:

[0048] Obtain the data storage space usage and the second resource unit consumption for each of the pending second resource processing transactions;

[0049] The second resource consumption is calculated based on the data storage space occupancy and the second resource unit consumption.

[0050] Optionally, in some embodiments, the method for determining the second resource unit consumption of the first target block specifically includes the following steps:

[0051] Obtain the third resource unit consumption, resource usage, third preset total resource amount, and resource change rate of the second target block, where the second target block is the block preceding the first target block;

[0052] The target change multiple is obtained by numerically processing the resource usage, the third preset total resource amount, and the resource change rate.

[0053] The second resource consumption of the first target block is determined based on the third resource unit consumption and the target change factor.

[0054] According to one aspect of this disclosure, a computer device is provided, including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement the blockchain transaction processing method as described above.

[0055] According to one aspect of this disclosure, a storage medium is provided that stores a computer program, which, when executed by a processor, implements the blockchain transaction processing method as described above.

[0056] According to one aspect of this disclosure, a computer program product is provided, the computer program product including a computer program that is read and executed by a processor of a computer device, causing the computer device to perform the blockchain transaction processing method as described above.

[0057] The blockchain transaction processing method provided in this disclosure is applied to a first-layer network node of a preset blockchain network. The preset blockchain network includes a first-layer network and a second-layer network. The first-layer network node is a node that generates blocks in the first-layer network. The method obtains multiple first resource processing transactions and multiple second resource processing transactions from a set of pending resource processing transactions. The first resource processing transactions are resource processing transactions generated based on resource exchange events between nodes in the first-layer network, and the second resource processing transactions are resource processing transactions generated based on resource exchange events between nodes in the second-layer network. A block body is generated based on the multiple first resource processing transactions. Temporary storage data is generated based on the multiple second resource processing transactions. A first target block is generated based on the block body and the temporary storage data, and the first target block is sent to a consensus node in the first-layer network for verification. When the verification result returned by the consensus node determines that the first target block has passed verification, the first target block is broadcast to every node in the first-layer network, and the world state of the first-layer network is updated based on the block body.

[0058] Therefore, during block generation, the resource exchange event data of the Layer 2 network is packaged and stored as temporary storage data in the temporary storage area of ​​the block. Furthermore, after the block is verified, the world state of the Layer 1 network is updated only based on the resource exchange event data of the Layer 1 network in the block body. There is no need to package the resource exchange event data of the Layer 2 network in the temporary storage area into the block body and participate in the update of the world state of the Layer 1 network, thereby reducing the expansion of the world state of the Layer 1 network. The decrease in the rate of world state expansion can reduce the complex scaling requirements of the blockchain, thereby improving the processing efficiency of blockchain transactions.

[0059] Other features and advantages of this disclosure will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the disclosure. The objectives and other advantages of this disclosure may be realized and obtained by means of the structures particularly pointed out in the description, claims and drawings. Attached Figure Description

[0060] The accompanying drawings are provided to further understand the technical solutions of this disclosure and constitute a part of the specification. They are used together with the embodiments of this disclosure to explain the technical solutions of this disclosure and do not constitute a limitation on the technical solutions of this disclosure.

[0061] Figure 1A This is a schematic diagram of the architecture of the blockchain network publicly provided.

[0062] Figure 1B This is a schematic diagram of the block structure in a blockchain;

[0063] Figure 1CThis is a schematic diagram of the block generation process in a blockchain;

[0064] Figure 2 This is a schematic diagram of the system architecture used in the blockchain transaction processing method according to embodiments of the present disclosure;

[0065] Figure 3 This is a flowchart illustrating the blockchain transaction processing method provided in this disclosure;

[0066] Figure 4 A structural diagram of the first target block;

[0067] Figure 5 A schematic diagram illustrating the process of generating block header data;

[0068] Figure 6 Another flowchart illustrating the blockchain transaction processing method provided in this disclosure;

[0069] Figure 7 A schematic diagram of the process of generating blocks;

[0070] Figure 8 This is a schematic diagram of the structure of a blockchain transaction processing device provided in an embodiment of the present disclosure;

[0071] Figure 9 This is a terminal structure diagram for implementing various methods according to an embodiment of the present disclosure;

[0072] Figure 10 This is a server structure diagram illustrating the implementation of various methods according to an embodiment of the present disclosure. Detailed Implementation

[0073] To make the objectives, technical solutions, and advantages of this disclosure clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and are not intended to limit the scope of this disclosure.

[0074] Before providing a further detailed description of the embodiments of this disclosure, the terms and concepts used in these embodiments are explained, and they are subject to the following interpretations:

[0075] Blockchain: A blockchain is a chain of blocks. Each block stores specific information, and these blocks are linked together in chronological order of their creation. This chain is stored on all servers within the blockchain network. As long as one server in the entire system is operational, the entire blockchain is secure. These servers are called nodes in the blockchain system, and they provide storage space and computing power for the entire system. To modify information in the blockchain, the consent of more than half of the nodes must be obtained, and the information in all nodes must be modified. Since these nodes are usually controlled by different entities, tampering with information in the blockchain is extremely difficult. Compared to traditional networks, blockchain has two core characteristics: data is difficult to tamper with, and it is decentralized. Based on these two characteristics, the information recorded by the blockchain is more authentic and reliable, helping to solve the problem of mutual distrust.

[0076] Block: In most blockchain implementations, the unit of data storage on the chain is the block number, which is also the block height.

[0077] Node: A service in a blockchain. A blockchain is generally composed of multiple nodes, and each node starts a blockchain software service.

[0078] Uploading to the blockchain: Data is stored in the database of the blockchain, which is called uploading to the blockchain.

[0079] Layer 1 network: This typically refers to the base layer blockchain, which is the cornerstone for building decentralized applications (DApps) and smart contracts. Layer 1 networks are responsible for handling resource exchange events, executing smart contracts, and maintaining network security and decentralization.

[0080] Layer 2 networks are solutions built on top of Layer 1 networks. Their purpose is to improve the speed of resource exchange events, reduce the resource consumption of these events, and enhance network scalability. Layer 2 networks reduce the burden on the main chain through off-chain computation and communicate periodically with the Layer 1 network through various mechanisms to ensure the security and finality of resource exchange events.

[0081] World state: refers to the state in which all nodes are completely consistent after executing resource exchange events within the same numbered block. The world state records various information, such as remaining resources, smart contract bytecode, and custom data, representing the current state, that is, the current value of each recorded state data.

[0082] Sequential node: refers to a node that confirms and executes the resource exchange order of resource exchange events in a Layer 2 network and submits it to a Layer 1 network.

[0083] Fraud Proof: In blockchain networks, fraud proof is a monitoring mechanism that enables participants to verify whether the execution of resource exchange events or smart contracts conforms to predetermined rules and protocols. If the execution result is found to be inconsistent with expectations, or if there is any violation, participants can issue a fraud proof to demonstrate the impropriety in the actual execution process.

[0084] Layer 2 blockchain technology is considered an effective way to extend blockchain performance. A Layer 2 network is an additional network built on top of a Layer 1 network to handle a large number of resource exchange events and smart contract calls, thereby improving the scalability and efficiency of the entire system. Layer 2 networks reduce the load on the Layer 1 network by processing a large number of resource exchange events outside of it and then submitting the results in batches to the Layer 1 network. Specifically, resource exchange events occur between nodes in the Layer 2 network. Sequential nodes in the Layer 2 network execute these resource exchange events, compress and package them, and send them to nodes in the Layer 1 network. The Layer 1 nodes then generate their own resource exchange events based on the data from the Layer 2 resource exchange events using smart contracts, and send these events to the nodes that have won block generation rights in the Layer 1 network. The nodes that have won block generation rights then generate a block body based on the aforementioned Layer 1 resource exchange events (data from the Layer 2 resource exchange events). Finally, a block header is generated based on this block body, and a new block is created based on the generated block body and block header. Finally, the world state of the first-layer network is updated based on this block. Therefore, resource exchange events between nodes in the second-layer network also occupy the space of the world state of the first-layer network, causing the world state of the first-layer network to continuously expand.

[0085] However, data on resource exchange events between nodes in a Layer 2 network typically does not require long-term storage. It is only necessary to retrieve this data from the Layer 1 network's world state when a node in the Layer 2 network fails, to re-examine and verify the process of these resource exchange events, and to ensure that the execution results are consistent with those recorded on the blockchain. Alternatively, if a node in the Layer 2 network engages in malicious activity, this data must be retrieved from the Layer 1 network's world state, executed to perform fraud proof, and to identify whether the node has acted maliciously. Since the storage resources for the world state are limited, as the Layer 2 network continuously writes data to the Layer 1 network's world state, the Layer 1 network's world state may continuously expand, leading to a decrease in the efficiency of blockchain transaction processing. Therefore, to address the problem of resource exchange events between nodes in the Layer 2 network occupying the Layer 1 network's world state and causing low efficiency in blockchain transaction processing, this disclosure provides a blockchain transaction processing method to reduce the expansion of the Layer 1 network's world state and improve the efficiency of blockchain transaction processing.

[0086] System architecture and scenario description of the embodiments disclosed herein

[0087] Figure 1A This is a schematic diagram of the architecture of the blockchain network disclosed herein. Specifically, the blockchain network can be a data sharing system 100, which includes multiple nodes 101, which can refer to various clients within the data sharing system. Each node 101, during normal operation, can receive input information and maintain shared data within the data sharing system based on the received input information. To ensure information exchange within the data sharing system, information connections can exist between each node, allowing for information transmission between nodes. For example, when any node in the data sharing system receives input information, other nodes in the system obtain this input information according to a consensus algorithm and store it as data in the shared data, ensuring consistency of data stored on all nodes in the data sharing system.

[0088] Each node in the data sharing system has a corresponding node identifier, and each node can also store the node identifiers of other nodes in the data sharing system. This allows for the subsequent broadcasting of generated blocks to other nodes in the data sharing system based on their node identifiers. Each node can maintain a node identifier list as shown in the table below, storing the node name and node identifier in this list. The node identifier can be an IP (Internet Protocol) address or any other information that can be used to identify the node. Table 1 only uses IP addresses as an example.

[0089] Node Name Node identifier Node 1 xxx.xxx.xxx.xxx Node 2 xxx.xxx.xxx.xxx … … Node N xxx.xxx.xxx.xxx

[0090] Table 1. Node Identification Diagram

[0091] Each node in the data-sharing system stores the same blockchain. A blockchain consists of multiple blocks; see [link to blockchain documentation]. Figure 1B A blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores input information feature values, version number, timestamp, and difficulty value, while the block body stores the input information. The next block after the genesis block takes the genesis block as its parent block. The next block also includes a block header and a block body. The block header stores the input information feature values ​​of the current block, the block header feature values ​​of the parent block, version number, timestamp, and difficulty value, and so on. This ensures that the block data stored in each block is related to the block data stored in the parent block, guaranteeing the security of the input information in the blocks.

[0092] When generating the individual blocks in the blockchain, see Figure 1C When a node in the blockchain receives input information, it verifies the input information. After verification, it stores the input information in a memory pool and updates its hash tree used to record the input information. Then, it updates the timestamp to the time the input information was received and tries different random numbers multiple times to calculate the feature value, ensuring that the calculated feature value satisfies the following formula:

[0093] SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x)) <TARGET

[0094] Wherein, SHA256 is the feature value algorithm used to calculate the feature value; version (version number) is the version information of the relevant block protocol in the blockchain; prev_hash is the block header feature value of the parent block of the current block; merkle_root is the feature value of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, which is a fixed value for a period of time and is determined again after exceeding the fixed time period; x is a random number; TARGET is the feature value threshold, which can be determined based on nbits.

[0095] Thus, when a random number satisfying the above formula is calculated, the information can be stored accordingly, generating a block header and a block body to obtain the current block. Subsequently, the node where the blockchain resides sends the newly generated block to other nodes in its data sharing system based on the node identifiers of other nodes in the data sharing system. The other nodes then verify the newly generated block and add it to their stored blockchain after verification.

[0096] Node 101 can be either a terminal or a server. When Node 101 is a terminal, it can take various forms, such as desktop computers, laptops, PDAs (personal digital assistants), mobile phones, in-vehicle terminals, home theater terminals, and dedicated terminals. Furthermore, it can be a single device or a collection of multiple devices. Node 101 can communicate with other nodes and exchange data via wired or wireless means.

[0097] When node 101 is a server, node 101 can be a high-performance computer in the blockchain network, a cluster of multiple high-performance computers, a portion of a high-performance computer (e.g., a virtual machine), or a combination of portions of multiple high-performance computers (e.g., virtual machines).

[0098] Figure 2This is a schematic diagram of the system architecture applied to the blockchain transaction processing method according to embodiments of this disclosure. It includes a blockchain network 200, first-layer network nodes 210, block generation nodes 211, second-layer network nodes 220, and sequencing nodes 221. The blockchain network 200 has already been described and will not be repeated here. The blockchain network 200 includes a first-layer network and a second-layer network. First-layer network nodes 210 can directly process resource exchange events between first-layer network nodes 210 on the blockchain, while second-layer network nodes 220 can process resource exchange events between nodes in the second-layer network outside the main chain, and then submit the results of these resource exchange events to the main chain. Specifically, in the first-layer network, resource exchange events between first-layer network nodes 210 can be stored in the pending resource processing transaction set of the blockchain network 200. In the second-layer network, resource exchange events are generated between second-layer network nodes 220. Further, sequencing nodes 221 can collect, compress, package, and send the results of resource exchange events between nodes in the second-layer network to a specific first-layer network node 210. Furthermore, this first-layer network node 210 can generate a first-layer network resource exchange event based on the result of the resource exchange event between nodes in the second-layer network using a smart contract. This first-layer network resource exchange event can also be stored in the pending resource processing transaction set of the blockchain network 200. The block generation node 211 can obtain the resource exchange event between the first-layer network nodes 210 from the pending resource processing transaction set of the blockchain network 200, and use the resource exchange event between the first-layer network nodes 210 to generate the block body of a new block; the block generation node 211 can also obtain the first-layer network resource exchange event of the same type as the resource exchange event between the first-layer network nodes 210 generated from the pending resource processing transaction set of the blockchain network 200, and can generate temporary storage data for a new block based on the resource exchange event generated from the first-layer network resource exchange event generated from the result of the resource exchange event between nodes in the second-layer network. Finally, after the aforementioned new block is verified by the consensus nodes, the block generating node 211 broadcasts the first target block to every node in the first-layer network and updates the world state of the first-layer network based on the block body.

[0099] The blockchain transaction processing method disclosed herein can be specifically applied to block generation node 211 in a preset blockchain network. The preset blockchain network includes a first-layer network and a second-layer network, and block generation node 211 is a node that generates blocks in the first-layer network. When the blockchain transaction processing method provided in this disclosure is applied to the block generation node 211 of a preset blockchain network, the block generation node 211 obtains multiple first resource processing transactions and multiple second resource processing transactions from the set of pending resource processing transactions. The first resource processing transactions are resource processing transactions generated based on resource exchange events between first-layer network nodes 210 in the first-layer network, and the second resource processing transactions are resource processing transactions generated based on resource exchange events between second-layer network nodes 220 in the second-layer network. The block generation node 211 generates a block body based on the multiple pending first resource processing transactions. The block generation node 211 generates temporary storage data based on the multiple pending second resource processing transactions. The block generation node 211 generates a first target block based on the block body and the temporary storage data, and sends the first target block to the consensus node in the first-layer network for verification. When the verification result returned by the consensus node determines that the first target block has passed verification, the block generation node 211 broadcasts the first target block to every node in the first-layer network and updates the world state of the first-layer network based on the block body.

[0100] The embodiments disclosed herein can be applied in various scenarios, such as in a financial institution's blockchain network where nodes process resource transactions, or in a judicial institution's blockchain network where resource transactions are processed.

[0101] For example, when the blockchain transaction processing method provided in this embodiment is applied to a first-layer network node in a financial institution's blockchain network, the financial institution's blockchain network includes a first-layer network and a second-layer network. First-layer network nodes are nodes that generate blocks within the first-layer network. Nodes in the first-layer network of the financial institution's blockchain network can directly process resource processing transactions between nodes in the first-layer network on the blockchain, i.e., the first resource processing transaction, to ensure the transparency, immutability, and finality of the resource processing transaction. Nodes in the second-layer network can perform resource exchange events (e.g., high-frequency, low-value resource exchange events) and then submit the results of the resource exchange events (e.g., the net settlement result of high-frequency, low-value resource exchange events) to the target first-layer network node to reduce congestion on the main chain and lower costs. The target first-layer network node generates a second resource processing transaction based on the resource exchange events between nodes in the second-layer network. Both the first and second resource processing transactions can be stored in the set of pending resource processing transactions in the financial institution's blockchain network. In a financial institution's blockchain network, a first-layer network node can first obtain multiple pending first resource processing transactions and multiple pending second resource processing transactions from the set of pending resource processing transactions. Then, it generates a block body based on the multiple pending first resource processing transactions and generates temporary storage data based on the multiple pending second resource processing transactions. Afterward, the first-layer network node generates a first target block based on the block body and the temporary storage data, and sends the first target block to the consensus node in the first-layer network for verification. When the verification result returned by the consensus node determines that the first target block has passed verification, the first target block is broadcast to every node in the first-layer network, and the world state of the first-layer network is updated based on the block body.

[0102] For example, when the blockchain transaction processing method provided in this embodiment is applied to a first-layer network node in a judicial institution blockchain network, the judicial institution blockchain network includes a first-layer network and a second-layer network. First-layer network nodes are nodes that generate blocks within the first-layer network. Nodes in the first-layer network of the judicial institution blockchain network can directly process resource processing transactions between nodes in the first-layer network (e.g., storing hash values ​​or metadata of key evidence), i.e., the first resource processing transaction, on the blockchain to ensure the integrity and immutability of the evidence. Nodes in the second-layer network can perform resource exchange events (e.g., processing evidence collection, organization, and preprocessing transactions), and then submit the results of the resource exchange events (e.g., a summary or citation of the evidence) to the target first-layer network node for preservation, thereby reducing congestion on the main chain and lowering costs. The target first-layer network node generates a second resource processing transaction based on the resource exchange events between nodes in the second-layer network. Both the first and second resource processing transactions can be stored in the set of pending resource processing transactions in the judicial institution blockchain network. In a judicial institution's blockchain network, a first-layer network node can first obtain multiple pending first resource processing transactions and multiple pending second resource processing transactions from the set of pending resource processing transactions. Then, it generates a block body based on the multiple pending first resource processing transactions and generates temporary storage data based on the multiple pending second resource processing transactions. Afterward, the first-layer network node in the judicial institution's blockchain generates a first target block based on the block body and the temporary storage data, and sends the first target block to the consensus node in the first-layer network for verification. When the verification result returned by the consensus node determines that the first target block has passed verification, the first target block is broadcast to every node in the first-layer network, and the world state of the first-layer network is updated based on the block body.

[0103] The above examples do not limit the scope of protection in this case.

[0104] General Description of Embodiments in this Disclosure

[0105] According to one embodiment of this disclosure, a blockchain transaction processing method is provided. This method can be used in scenarios where blockchain transactions are processed at a first-layer network node in a financial institution's blockchain network, or in scenarios where blockchain transactions are processed at a first-layer network node in a judicial institution's blockchain network.

[0106] like Figure 3 The diagram shown is a flowchart of a blockchain transaction processing method provided in this disclosure. This method can be applied to a blockchain transaction processing device, which can be integrated into a computer device. Specifically, the computer device can be a first-layer network node in a pre-defined blockchain network. The pre-defined blockchain network includes a first-layer network and a second-layer network, with the first-layer network node being the node that generates blocks within the first-layer network. This blockchain transaction processing method may include:

[0107] Step 310: Obtain multiple pending first resource processing transactions and multiple pending second resource processing transactions from the set of pending resource processing transactions.

[0108] This disclosure provides a blockchain transaction processing method that reduces the expansion of the world state of a Layer 1 network, thereby improving the processing efficiency of blockchain transactions. Specifically, it provides a transaction processing scheme for resource exchange event data of a Layer 2 network. This scheme allows Layer 1 network nodes to package and store Layer 2 network resource exchange event data as temporary storage data in the temporary storage area of ​​the block during block generation. Furthermore, after the block is verified, the world state of the Layer 1 network is updated only based on the resource exchange event data of the Layer 1 network within the block body. There is no need to package the Layer 2 network resource exchange event data from the temporary storage area into the block body and participate in the update of the Layer 1 network's world state, thus reducing the expansion of the Layer 1 network's world state and improving the processing efficiency of blockchain transactions. The blockchain transaction processing method provided in this disclosure will be described in detail below.

[0109] The preset blockchain network can be any type of blockchain, such as a public chain, private chain, or consortium chain. The preset blockchain network includes a layer 1 network and a layer 2 network. Each layer 1 and layer 2 network consists of multiple nodes. Each node in the layer 1 network maintains a ledger, i.e., the blockchain. Specifically, a layer 1 network node is a node that generates blocks within the layer 1 network; that is, a node that has won the right to generate blocks within the layer 1 network.

[0110] In a blockchain, the set of pending resource processing transactions can be a collection of all resource processing transactions that have not yet been processed or confirmed. These transactions may involve the transfer, exchange, or other operations of virtual resources, or they may be exchanges of other non-virtual resources. For example, when a resource exchange object initiates a new resource processing transaction, this new transaction is added to the set of pending resource processing transactions, waiting to be selected by a layer of network nodes and packaged into a block.

[0111] The first resource processing transaction can be a resource processing transaction generated based on resource exchange events between nodes in a Layer 1 network, and the second resource processing transaction can be a resource processing transaction generated based on resource exchange events between nodes in a Layer 2 network.

[0112] Specifically, the process of generating the first resource processing transaction may include: in a layer-one network, resource exchange events occur between nodes in the layer-one network, which constitute the first resource processing transaction. Afterwards, the first resource processing transaction can be stored in the set of pending resource processing transactions in a pre-defined blockchain network.

[0113] The specific process of generating a second resource processing transaction may include: First, resource exchange events are generated between nodes in the Layer 2 network. Then, these resource exchange events are sent to the ordering nodes of the Layer 2 network, or the ordering nodes of the Layer 2 network collect these resource exchange events. Next, the nodes in the Layer 2 network execute the resource exchange events and send the data to the ordering nodes. Then, the ordering nodes compress and package the data and send it to the target Layer 1 network node (either a regular node or a consensus node in the Layer 1 network). Finally, the target Layer 1 network node generates a Layer 1 network resource exchange event (i.e., the second resource processing transaction) based on the Layer 1 network's smart contract using the aforementioned data from the Layer 2 resource exchange events. The second resource processing transaction can then be stored in a pre-defined set of pending resource processing transactions within the blockchain network.

[0114] When nodes in a Layer 1 network generate a first resource exchange transaction, they can add a tag to the transaction, such as TYPE1. When a target Layer 1 network node generates a second resource exchange transaction based on the data of the resource exchange events between nodes in the aforementioned Layer 2 network using the Layer 1 network's smart contract, it can add a TYPE2 tag to the second resource exchange transaction. In this way, a Layer 1 network node can select multiple first resource processing transactions to be processed from the set of pending resource processing transactions based on TYPE1 type, and multiple second resource processing transactions to be processed based on TYPE2 type.

[0115] Step 320: Generate a block based on multiple pending first resource processing transactions.

[0116] In blockchain technology, a block consists of two main parts: a block header and a block body. The block body typically contains a series of records of resource processing transactions, which can be packaged into a list of resource processing transactions for that block.

[0117] In related technologies, resource exchange transactions generated from resource exchange events between nodes in a Layer 1 network and resource exchange transactions generated from data packaging of resource exchange events between nodes in a Layer 2 network are both resource processing transactions of the Layer 1 network. There is no distinction between the first and second resource processing transactions as in the embodiments of this disclosure. Because the two types of resource exchange transactions have equal status, Layer 1 network nodes package and sort these two types of resource exchange transactions according to preset rules, and generate blocks based on these two types of resource exchange transactions. Therefore, the world state of the Layer 1 network expands very quickly. As the world state of the Layer 1 network expands rapidly, nodes need to compute more resources when processing each block, leading to a decrease in the processing efficiency of blockchain transactions.

[0118] In this embodiment of the disclosure, to avoid the problem in related technologies where resource exchange transactions in the Layer 2 network participate in block generation, leading to rapid expansion of the world state of the Layer 1 network and consequently low processing efficiency of blockchain transactions, this disclosure distinguishes between resource processing transactions generated by resource exchange events between nodes in the Layer 1 network (designated as first resource processing transactions) and resource processing transactions generated by resource exchange events between nodes in the Layer 2 network (designated as second resource processing transactions). Block generation is then performed based on the first resource processing transaction, thereby preventing resource exchange events between nodes in the Layer 2 network from occupying the world state of the Layer 1 network.

[0119] In this way, after the block is verified, the world state of the first-layer network is updated only based on the resource exchange event data of the first-layer network in the block body. There is no need to package the resource exchange event data of the second-layer network in the temporary storage area into the block body and participate in the update of the world state of the first-layer network, thereby reducing the expansion of the world state of the first-layer network and improving the processing efficiency of blockchain transactions.

[0120] In some embodiments, generating a block body based on a plurality of pending first resource processing transactions includes:

[0121] The first resource processing transactions are sorted according to the first resource unit consumption of each first resource processing transaction to obtain the first resource processing transaction sequence.

[0122] Calculate the first resource consumption corresponding to each first resource processing transaction based on the first resource unit consumption.

[0123] The first target resource processing transaction is determined in the first resource processing transaction sequence based on the first preset total resource amount and the first resource consumption amount corresponding to the first target block.

[0124] A block body is generated based on the transaction processing of the first target resource.

[0125] This disclosure provides a method for determining a first target resource processing transaction in a first resource processing transaction sequence using a first preset total resource amount and a first resource consumption amount corresponding to a first target block, and generating a block body based on the first target resource processing transaction.

[0126] The first resource unit consumption can be the resource unit consumption set by the resource exchange object for executing the first resource processing transaction. The higher the first resource unit consumption set by the resource exchange object, the more likely the published first resource processing transaction is to be processed preferentially by the first-layer network nodes. The first resource unit consumption of each pending first resource processing transaction can be the same or different. The first-layer network nodes can sort multiple pending first resource processing transactions according to the size of the first resource unit consumption of each pending first resource processing transaction. For example, based on the size of the first resource unit consumption of each pending first resource processing transaction, multiple pending first resource processing transactions can be sorted in descending order to obtain a sequence of first resource processing transactions.

[0127] Specifically, the first resource consumption can be the virtual resources required for a layer-one network node to execute the first resource processing transaction, or it can be non-virtual resources. The first preset total resource amount corresponding to the first target block can be the maximum number of first resource processing transactions that the first target block can process.

[0128] Based on the first preset total resource amount and the first resource consumption amount corresponding to the first target block, multiple first resource processing transactions, namely first target resource processing transactions, are determined in the first resource processing transaction sequence.

[0129] It should be noted that the resources exchanged in the resource exchange events between nodes in the first and second resource processing transactions are not the same as the resources consumed in the aforementioned first resource consumption. For example, the resources exchanged in the resource exchange events between nodes in the first and second resource processing transactions can be a medium such as currency. However, the resources consumed in the first resource consumption can be the computing resources required for a layer-one network node to perform a specific operation or contract.

[0130] In some embodiments, determining a first target resource processing transaction in a first resource processing transaction sequence based on a first preset total resource amount corresponding to a first target block and a first resource consumption amount includes:

[0131] Based on the sorting order of the first resource processing transactions in the first resource processing transaction sequence, the corresponding first resource consumption is accumulated to obtain the cumulative resource consumption value.

[0132] When the cumulative value of resource consumption exceeds the first preset total resource amount, the first resource processing transaction that ranks before the critical resource processing transaction corresponding to the cumulative value of resource consumption is determined as the first target resource processing transaction.

[0133] This disclosure provides a method for determining a first target resource processing transaction in a first resource processing transaction sequence using a first preset total resource amount corresponding to a first target block and a first resource consumption amount.

[0134] The first preset total resource amount can be the upper limit of resource consumption for processing the first resource processing transaction pre-set in the first target block. The cumulative resource consumption value can be the cumulative resource consumption value obtained by summing the first resource consumption amounts of the first resource processing transactions. Specifically, a layer-one network node can accumulate the first resource consumption amounts of the corresponding first resource processing transactions according to the sorting order of the first resource processing transactions in the first resource processing transaction sequence to obtain the cumulative resource consumption value. Further, the first resource processing transaction corresponding to the cumulative resource consumption value being greater than the first preset total resource amount can be identified as a critical resource processing transaction. Further, the first resource processing transactions (excluding the aforementioned critical resource processing transactions) that are ranked before the critical resource processing transactions corresponding to the cumulative resource consumption value can be identified as the first target resource processing transactions.

[0135] Following the order of the first resource processing transactions in the first resource processing transaction sequence, the resource consumption of each first resource processing transaction is accumulated to approximate the first preset total resource amount corresponding to the first target block. This determines the first target resource processing transaction used to generate the block body, allowing layer-one network nodes to process as many first resource processing transactions in the first resource processing transaction sequence as possible. It should be noted that the number of first target resource processing transactions can be one or more.

[0136] Step 330: Generate temporary storage data based on multiple pending second resource processing transactions.

[0137] In this embodiment of the disclosure, to avoid the problem in related technologies where the participation of second resource processing transactions in block generation leads to rapid expansion of the world state of the first-layer network, resulting in low processing efficiency of blockchain transactions, the inventors of this disclosure design a new area in the block, which can be called a temporary storage area. The temporary storage area can be used to store temporary storage data (resource exchange event data of the second-layer network). The temporary storage data stored in the temporary storage area does not participate in the updating of the world state of the first-layer network; it is only stored by the nodes of the first-layer network for a period of time (e.g., 14 days). This ensures that resource exchange objects that are interested in the resource exchange event data of the second-layer network can download the data. While ensuring the security of the second-layer network, it avoids the expansion of the world state of the first-layer network, thereby improving the processing efficiency of blockchain transactions.

[0138] Specifically, temporary storage data can be generated based on multiple pending second resource processing transactions. Further, this temporary storage data can be stored in the temporary storage area of ​​the block.

[0139] In some embodiments, temporary storage data is generated based on a plurality of pending second resource processing transactions, including:

[0140] The multiple pending second resource processing transactions are sorted according to the second resource consumption corresponding to each pending second resource processing transaction to obtain a second resource processing transaction sequence.

[0141] The second target resource processing transaction is determined in the second resource processing transaction sequence based on the second preset total resource amount and the second resource consumption of the first target block.

[0142] Temporary storage data is generated based on the transaction processing of the second target resource.

[0143] This disclosure provides a method for determining a second target resource processing transaction in a second resource processing transaction sequence using a second preset total resource amount corresponding to a first target block and a second resource consumption amount.

[0144] The second resource consumption can be the resources required for a regular node in a Layer 1 network to execute a specific second resource processing transaction. The second preset total resource corresponding to the first target block can be the upper limit of resource consumption for processing second resource processing transactions pre-set in the first target block.

[0145] Specifically, a first-layer network node can first calculate the second resource consumption corresponding to each pending second resource processing transaction. Further, the first-layer network node can sort multiple pending second resource processing transactions according to the second resource consumption of each pending second resource processing transaction to obtain a second resource processing transaction sequence. Further, the first-layer network node can determine the second target resource processing transaction within the second resource processing transaction sequence based on the second preset total resource amount and the second resource consumption of the first target block. For example, the first-layer network node can accumulate the second resource consumption of the corresponding second resource processing transactions according to their order in the second resource processing transaction sequence. When the accumulated resource consumption is greater than the second preset total resource amount, the corresponding second resource processing transaction can be determined as a critical second resource processing transaction. Further, second resource processing transactions ranked before the critical second resource processing transactions (excluding the aforementioned critical second resource processing transactions) can be determined as second target resource processing transactions. Finally, the first-layer network node can generate temporary storage data based on the second target resource processing transactions.

[0146] Following the sequential order of the second resource processing transactions in the second resource processing transaction sequence, the second resource consumption of each second resource processing transaction is accumulated to approximate the second preset total resource amount corresponding to the first target block. This determines the second target resource processing transaction used to generate temporary storage data, allowing layer-one network nodes to process as many second resource processing transactions in the second resource processing transaction sequence as possible. It should be noted that the number of second target resource processing transactions can be one or more.

[0147] In some embodiments, the calculation process for the second resource consumption of each pending second resource processing transaction specifically includes the following steps:

[0148] Obtain the data storage space usage and second resource unit consumption for each pending second resource processing transaction;

[0149] The consumption of the second resource is calculated based on the data storage space occupied and the consumption of the second resource unit.

[0150] This disclosure provides a method for calculating the consumption of a second resource using the data storage space occupancy of each pending second resource processing transaction and the consumption of a second resource unit.

[0151] The data storage space required for each pending second resource processing transaction can be defined as the storage space required for the data of each pending second resource processing transaction. The second resource unit consumption can be set by the ordering node of the Layer 2 network as the resource unit consumption for executing the second resource processing transaction.

[0152] Specifically, a first-layer network node can first obtain multiple pending second resource processing transactions from the set of pending resource processing transactions. Further, the first-layer network node can obtain the data storage space occupancy and second resource unit consumption of each pending second resource processing transaction. Further, the first-layer network node can calculate the second resource consumption based on the data storage space occupancy and the second resource unit consumption; the second resource consumption of each pending second resource processing transaction can be the product of the data storage space occupancy and the second resource unit consumption. The higher the second resource consumption of each pending second resource processing transaction, the more likely the published second resource processing transaction is to be processed preferentially by the first-layer network node.

[0153] In some embodiments, the method for determining the second resource unit consumption of the first target block specifically includes the following steps:

[0154] Obtain the third resource unit consumption, resource usage, third preset total resource amount, and resource change rate of the second target block. The second target block is the block preceding the first target block.

[0155] The target change factor is obtained by numerically processing the resource usage, the third preset total resource amount, and the resource change rate.

[0156] The second resource consumption of the first target block is determined based on the third resource unit consumption and the target change factor.

[0157] This disclosure provides a method for determining the second resource unit consumption of a first target block based on resource usage, a third preset total resource amount, resource change rate, and a third resource unit consumption.

[0158] As described above, nodes in the Layer 2 network execute resource exchange events between nodes in the Layer 2 network, obtaining data of these events. Then, these nodes send this data to the ordering nodes in the Layer 2 network. The ordering nodes compress and package this data before sending it to the target Layer 1 network node (either a regular node or a consensus node in the Layer 1 network). Further, the target Layer 1 network node, based on the Layer 1 network's smart contract, generates a Layer 1 network resource exchange event—the second resource processing transaction—from the aforementioned Layer 2 resource exchange event data. Layer 1 network nodes first generate temporary storage data based on multiple pending second resource processing transactions. This temporary storage data can then be stored in the temporary storage area of ​​the block.

[0159] The second resource unit consumption set by the ordering node of the Layer 2 network for the second resource processing transaction executed by the Layer 1 network node can be updated in the following way: the second target block is the block preceding the first target block. The third resource unit consumption, resource usage, third preset total resource amount, and resource change rate of the second target block are obtained. The numerical values ​​of the resource usage, third preset total resource amount, and resource change rate are processed to obtain the target change multiple. The second resource consumption of the first target block is determined based on the third resource unit consumption and the target change multiple.

[0160] The third resource unit consumption can be the resource unit consumption set by the sequence nodes of the Layer 2 network in the second target block for executing the second resource processing transaction. The third preset total resource can be the upper limit of resource consumption for processing the second resource processing transaction in the second target block. Resource usage can be the total computing resources consumed by the temporary storage data stored in the temporary storage area of ​​the second target block. The resource change rate can be the change rate between each block set manually, and the resource change rate can be set at system startup, for example, it can be 8, 16, or 32.

[0161] Specifically, the ideal third preset resource quantity can be determined first based on the total preset resource quantity. This ideal third preset resource quantity can be the value obtained by dividing the total preset resource quantity by a preset value, which can be set by the system according to its own needs, for example, 2, 3, 4, or 5. Ideal third preset resource quantity = Total preset resource quantity / 2; Target change factor = 1 + [(Resource usage - Ideal third preset resource quantity) / (Ideal third preset resource quantity × Resource change rate)]. Finally, the second resource consumption of the first target block can be determined based on the third resource unit consumption and the target change factor, i.e., the second resource consumption of the first target block = Third resource unit consumption × Target change factor.

[0162] For example, if the third preset resource total for the second target block is set to 30 Million (M), the resource usage of the second target block is 30M, and the resource change rate is 8, then the third preset ideal resource amount is 30M / 2 = 15M, the target change multiple is 1 + (30M - 15M) / (15M × 8) = 1.125, and the second resource consumption of the first target block is equal to the third resource unit consumption × 1.125. This indicates that the second resource consumption of the first target block is 1.125 times the third resource unit consumption of the previous block (the second target block). At this point, the sequence nodes in the Layer 2 network can know that the Layer 2 network has a large storage demand for the temporary storage area, and that the second resource unit consumption needs to be increased when publishing resource exchange events between nodes in the Layer 2 network. When the third preset resource total amount of the second target block = 30M, the resource usage = 7.5M, and the resource change rate = 8, then the ideal third preset resource amount = 30M / 2 = 15M. Therefore, the target change multiple = 1 + (7.5M - 15M) / (15M × 8) = 0.9375. The second resource consumption of the first target block = the third resource unit consumption × 0.9375. This indicates that the second resource consumption of the first target block is 0.9375 times the third resource unit consumption of the previous block (the second target block).

[0163] The second resource unit consumption of the first target block can be adaptively adjusted based on the resource usage of the temporary storage area in the second target block. This adaptive adjustment mechanism can be agreed upon by the consensus nodes of the blockchain network. Therefore, the ordering nodes can assess the storage requirements of the second-layer network for the temporary storage area, allowing ordering nodes in different second-layer networks to change the second resource unit consumption to achieve a convergence expectation. Furthermore, the resource change rate can be controlled to be the rate of change of resource unit consumption between every two adjacent blocks. If the resource change rate is 8, the rate of change of resource unit consumption corresponding to a block can be from -12.5% ​​to 12.5%; if the resource change rate is 16, the rate of change of resource unit consumption corresponding to a block can be from -6.25% to 6.25%. The resource change rate can reduce the fluctuation of resource unit consumption in the temporary storage area.

[0164] Through this objective adaptive adjustment mechanism for resource unit consumption, different ordered nodes in the second-layer network can quickly and objectively assess a reasonable second resource unit consumption. This adaptive adjustment mechanism for resource unit consumption gives the second resource unit consumption a convergent expected value, which can avoid excessive fluctuations in the second resource unit consumption and also avoid excessive resource consumption.

[0165] Step 340: Generate a first target block based on the block body and temporary storage data, and send the first target block to the consensus node in the first layer network for verification.

[0166] In a Layer 1 network, some nodes among the multiple nodes in the Layer 1 network determine multiple consensus nodes by staking resources and voting by all nodes in the blockchain network. The consensus nodes participate in block generation and block verification and receive corresponding rewards.

[0167] Specifically, a Layer 1 network node can first obtain multiple pending first resource processing transactions and multiple pending second resource processing transactions from the set of pending resource processing transactions. Further, a Layer 1 network node can generate a block body based on the multiple pending first resource processing transactions, and can generate temporary storage data based on the multiple pending second resource processing transactions. Further, a Layer 1 network node can generate a block header based on the generated block body. Then, a Layer 1 network node generates a block, i.e., the first target block, based on the block body, temporary storage data, and block header. The Layer 1 network node can send the first target block to the consensus nodes in the Layer 1 network for verification. Finally, when the nodes in the Layer 1 network reach a consensus, the first target block is broadcast to the entire blockchain network. After the first target block is added to the blockchain, the Layer 1 network nodes update the world state of the Layer 1 network based on the block body.

[0168] In some embodiments, generating a first target block based on the block body and temporary storage data, and sending the first target block to a consensus node in a Layer 1 network for verification includes:

[0169] Construct the block structure of the first target block, which includes a block header storage area, a block body storage area, and a temporary storage area;

[0170] Store temporary storage data in the temporary storage area and store block bodies in the block body storage area;

[0171] Generate block header data based on multiple pending first resource processing transactions in the block body, store the block header data in the block header storage area, and obtain the first target block;

[0172] The first target block is sent to the consensus node in the first-layer network for verification.

[0173] This disclosure provides a method for constructing a first target block and sending the first target block to a consensus node in a layer 1 network for verification.

[0174] like Figure 4The diagram shows a structural illustration of the first target block 400 provided in this disclosure. First, the block structure of the first target block 400 can be constructed, including a block header storage area 410, a block body storage area 420, and a temporary storage area 430. Further, a layer-one network node can generate temporary storage data based on multiple pending second resource processing transactions and store the temporary storage data in the temporary storage area 430. Simultaneously, a layer-one network node can generate a block body based on multiple pending first resource processing transactions and store the block body in the block body storage area 420. Further, a layer-one network node can generate block header data based on multiple pending first resource processing transactions in the block body, store the block header data in the block header storage area 410, and obtain the first target block 400; the first target block 400 is then sent to the consensus node in the layer-one network for verification.

[0175] In some embodiments, generating block header data based on multiple pending first resource processing transactions in the block body, and storing the block header data in the block header storage area includes:

[0176] Calculate the hash value of the first resource processing transaction to be processed in each block body;

[0177] The Merkle root is calculated based on the hash value and stored in the block header storage area.

[0178] This disclosure provides a method for generating block header data based on multiple pending first resource processing transactions in a block body, and storing the block header data in a block header storage area.

[0179] like Figure 5 The diagram illustrates a process for generating block header data as provided in this disclosure. In the first target block, the block header storage area 510 primarily stores some relevant attributes of the block, while the block body storage area 520 stores the data records of multiple pending first resource processing transactions. A block is connected to a parent block and a child block. The block header data mainly consists of three sets of data: the first set is the hash value of the parent block, used to connect the block to its preceding block; the second set includes the difficulty, timestamp, and random number; the third set is the root hash value calculated from multiple pending first resource processing transactions in the block body, i.e., the Merkle root. The block body includes multiple pending first resource processing transactions, for example... Figure 5 The first resource processing transactions are 1, 2, 3, and 4. These pending first resource processing transactions generate unique Merkle roots through a Merkle tree hashing process and are recorded in the block header storage area 510.

[0180] It should be noted that Merkle trees can be used to summarize all first resource processing transactions in a block, generate a digital fingerprint of the entire set of first resource processing transactions, and provide an efficient way to verify whether a block contains a certain first resource processing transaction. Generating a complete Merkle tree requires recursively hashing hash node pairs and inserting the newly generated hash nodes into the Merkle tree until only one hash node remains; this node is the root of the Merkle tree.

[0181] Specifically, a layer-one network node calculates the hash value of each pending first resource processing transaction in the block body. Further, the layer-one network node can calculate the Merkle root based on the hash value and store the Merkle root in the block header storage area 510. For example, a layer-one network node can calculate the hash values ​​of first resource processing transactions 1, 2, 3, and 4 respectively, obtaining hash 1 for first resource processing transaction 1, hash 2 for first resource processing transaction 2, hash 3 for first resource processing transaction 3, and hash 4 for first resource processing transaction 4. Further, the layer-one network node can recursively generate hash 1234 from hash 1, hash 2, hash 3, and hash 4, where hash 1234 is the unique Merkle root generated from first resource processing transactions 1, 2, 3, and 4. Finally, the layer-one network node can store the Merkle root in the block header storage area 510.

[0182] Step 350: When the verification result returned by the consensus node determines that the first target block has passed the verification, the first target block is broadcast to every node in the first layer network, and the world state of the first layer network is updated based on the block body.

[0183] After generating the first target block, the first-layer network node sends it to the consensus node in the first-layer network for verification. Further, the consensus node in the first-layer network generates a verification result using a consensus algorithm. When the consensus node returns a verification result indicating that the first target block has passed verification, the first-layer network node broadcasts the first target block to every node in the first-layer network. This block broadcasting process is typically implemented using a peer-to-peer network to ensure that every node in the first-layer network receives the new block information. Upon receiving the new block, each node in the first-layer network independently verifies its validity to ensure it conforms to the blockchain rules and network consensus. After verification by each node in the first-layer network, each node updates its locally stored world state based on the first resource processing transaction in the block body. Updating the world state of the first-layer network can include updating account resource balances, smart contract states, and other on-chain data. Finally, after updating the world state of the first-layer network, the first-layer network node adds the block to the end of its local blockchain, forming an extension of the blockchain.

[0184] In this embodiment of the disclosure, after the block is verified, the world state of the first-layer network is updated only based on the resource exchange event data of the first-layer network in the block body. There is no need to package the resource exchange event data of the second-layer network in the temporary storage area into the block body and participate in the update of the world state of the first-layer network, thereby reducing the expansion of the world state of the first-layer network and improving the processing efficiency of blockchain transactions.

[0185] In some embodiments, after determining that the first target block has passed verification based on the verification result returned by the consensus node, the first target block is broadcast to every node in the first-layer network, and the world state of the first-layer network is updated based on the block body, the method further includes:

[0186] Add the first target block to the target blockchain;

[0187] Identify the pending blocks in the target blockchain containing temporary storage data to be deleted.

[0188] Delete the temporary storage data stored in the block to be processed.

[0189] This disclosure provides a method for deleting temporary storage data stored in the block to be processed after updating the world state of a layer of network based on a block volume.

[0190] As previously described, after updating the world state of the Layer 1 network, each Layer 1 node adds the block to the end of its local blockchain, forming an extension of the blockchain. Since the data on resource exchange events between nodes in the Layer 2 network typically does not require long-term storage, it is only necessary to retrieve this data from the Layer 1 network's world state when a node in the Layer 2 network malfunctions or acts maliciously, to verify that the execution results of these resource exchange events match those recorded on the blockchain. Therefore, when it is not necessary to save the data on resource exchange events between nodes in the Layer 2 network stored in temporary storage, each node in the Layer 1 network can delete the temporary storage data of the first target block.

[0191] Specifically, when the first target block passes verification based on the verification results returned by the consensus nodes, the first target block is broadcast to every node in the first-layer network. After updating the world state of the first-layer network based on the block body, the first-layer network nodes can add the first target block to the target blockchain. Further, the first-layer network nodes can identify pending blocks in the target blockchain containing temporary storage data to be deleted. Finally, each node in the first-layer network can delete the temporary storage data stored in the pending blocks.

[0192] In some embodiments, identifying pending blocks of temporary storage data to be deleted in the target blockchain includes:

[0193] Obtain the first timestamp of each block in the target blockchain;

[0194] Based on the time difference between the first timestamp and the second timestamp of the first target block, the pending block of temporary storage data to be deleted is determined.

[0195] This disclosure provides a method for determining the pending block of temporary storage data to be deleted based on the time difference between the first timestamp of each block in the target blockchain and the second timestamp of the first target block.

[0196] Specifically, in the target blockchain, each node in the first layer of the network can first obtain the first timestamp of each block record, that is, the time stamp when the block was created and added to the chain. The first timestamp of each block provides the blockchain with an immutable and ordered time record. Next, each node in the first layer of the network can obtain the second timestamp corresponding to the first target block. By comparing the time difference between the second timestamp and the first timestamp of each block in the target blockchain, each node in the first layer of the network can calculate the time difference from when the first target block was added to the target blockchain to the latest block in the current target blockchain. Based on this time difference, it can be determined whether the temporary storage data of the first target block no longer needs to be retained. For example, if the blockchain protocol stipulates that temporary storage data only needs to be retained for a certain period of time, such as 14 days, then temporary storage data with a retention period exceeding 14 days can be deleted. If the time difference between the first timestamp of the latest block and the second timestamp of the first target block exceeds 14 days, then the first target block can be identified as a block containing temporary storage data to be deleted in the blockchain. Each node in the network layer can delete the temporary storage data stored in the temporary storage area of ​​the first target block. This process helps optimize the use of temporary storage data, ensuring that only relevant and necessary data is retained on the blockchain.

[0197] This disclosure embodiment analyzes the first timestamp of each block in the blockchain and compares it with the second timestamp of the first target block. This allows for the identification and management of temporary data that has exceeded the predetermined retention period, enabling each node in the layer network to periodically clean up the temporary storage data of the blocks to be processed.

[0198] In some embodiments, determining the pending blocks of temporary storage data to be deleted in the target blockchain further includes:

[0199] Obtain the first block height value of each block in the target blockchain;

[0200] Based on the block height difference between the first block height value and the second block height value of the first target block, the block to be processed for the temporary storage data to be deleted is determined.

[0201] This disclosure provides a method for determining the block to be processed containing temporary storage data to be deleted based on the block height difference between the first block height value of each block in the target blockchain and the second block height value of the first target block.

[0202] In a blockchain system, each block has an associated block height value, indicating its position within the blockchain. The height value increases starting from the genesis block (which typically has a height of 0 or 1).

[0203] Specifically, each node in the first-layer network first obtains the first block height value of each block in the target blockchain, which represents the block's sequential position in the chain. Next, each node in the first-layer network obtains the second block height value of the first target block. Based on the blockchain protocol's retention policy for temporary storage data—for example, it might stipulate that temporary storage data only needs to store a specific block height value—each node in the first-layer network can identify the block to be processed for temporary storage data deletion based on the calculated block height difference. For instance, if the block height difference between the first block height value corresponding to the latest block and the second block height value of the first target block exceeds a specific block height value that the temporary storage data only needs to store, then the first target block can be identified as the block to be processed for temporary storage data deletion in the blockchain, and each node in the first-layer network can delete the temporary storage data stored in the temporary storage area of ​​the first target block.

[0204] In summary, the blockchain transaction processing method provided in this disclosure is applied to a first-layer network node of a pre-defined blockchain network, which includes a first-layer network and a second-layer network. First-layer network nodes are nodes that generate blocks within the first-layer network. The method involves obtaining multiple first-layer resource processing transactions and multiple second-layer resource processing transactions from a set of pending resource processing transactions. The first-layer resource processing transactions are generated based on resource exchange events between nodes in the first-layer network, and the second-layer resource processing transactions are generated based on resource exchange events between nodes in the second-layer network. A block body is generated based on the multiple first-layer resource processing transactions. Temporary storage data is generated based on the multiple second-layer resource processing transactions. A first target block is generated based on the block body and the temporary storage data, and the first target block is sent to a consensus node in the first-layer network for verification. When the verification result returned by the consensus node indicates that the first target block has passed verification, the first target block is broadcast to every node in the first-layer network, and the world state of the first-layer network is updated based on the block body.

[0205] Therefore, when generating blocks, the resource exchange event data of the second-layer network is packaged and stored as temporary storage data in the temporary storage area of ​​the block; and after the block is verified, the world state of the first-layer network is updated only based on the resource exchange event data of the first-layer network in the block body, without having to package the resource exchange event data of the second-layer network in the temporary storage area into the block body and participate in the update of the world state of the first-layer network, thereby reducing the expansion of the world state of the first-layer network and improving the processing efficiency of blockchain transactions.

[0206] This disclosure provides a detailed description of embodiments in conjunction with specific application scenarios.

[0207] like Figure 6The diagram shown is another flowchart of the blockchain transaction processing method provided in this disclosure. This method is applied to a first-layer network node in a blockchain network, which includes a first-layer network and a second-layer network. The first-layer network node is the node that generates blocks in the first-layer network. The method specifically includes the following steps:

[0208] Step 601: The ordering node of the Layer 2 network obtains the resource exchange event of the Layer 2 network, compresses and packages the resource exchange event of the Layer 2 network, and sends it to the Layer 1 network node.

[0209] In a Layer 2 network, nodes generate resource exchange events, execute these events, and send the results to the ordering nodes. The ordering nodes then batch-submit the verified and ordered resource exchange events to the first-layer network nodes, ensuring the final state of the Layer 2 resource exchange events is recorded on the Layer 1 blockchain and thus guaranteeing its immutability.

[0210] The ordering nodes of the Layer 2 network compress and package the resource exchange event data of the Layer 2 network and send it to the first-layer network node of the Layer 1 network. The first-layer network node can be an ordinary node or a consensus node of the Layer 1 network.

[0211] Step 602: The first-layer network node generates a TYPE2 type resource exchange transaction based on the resource exchange event of the second-layer network.

[0212] After the Layer 2 network's sequencing nodes compress and package the Layer 2 network's resource exchange event data and send it to the first-layer network nodes in the Layer 1 network, the first-layer network nodes can generate a TYPE2 type resource exchange transaction based on a smart contract to publish the Layer 2 network's resource exchange event data to the Layer 1 network. A TYPE2 type resource exchange transaction can be a resource exchange event from the Layer 1 network.

[0213] To optimize transmission efficiency and reduce the storage burden on the Layer 1 network, the sequencing node compresses the resource exchange event data generated by the Layer 2 network nodes to maintain integrity while reducing data size. The sequencing node then packages the compressed data according to a specific logic, forming batches. The sequencing node sends the packaged and compressed data (along with necessary proofs) to the first-layer network node in the Layer 1 network. Data publication from the Layer 2 network to the Layer 1 network is typically accomplished by the first-layer network node creating a Layer 1 network resource exchange event on the Layer 1 network.

[0214] Over a period of time, the sequence node collects data on resource exchange events generated by nodes in the Layer 2 network, compresses the data, and obtains TxData. A TYPE2 type resource exchange transaction Tx2 can be represented by the following equation (1):

[0215] Tx2=(From2,To2,CallData2,GasPrice2,Type2,Sig2) (1)

[0216] Where From2 is the resource address of the sequencer node in the Layer 1 network; To2 is empty; CallData2 is the aforementioned TxData, representing the data of the resource exchange event of the Layer 2 network to be published to the BLOB (Binary Large Object) space of the block. Here, BLOB usually refers to a large binary object, and the BLOB space can store a large amount of data; Type2 is a new field added to the resource exchange event in this embodiment of the disclosure, where TYPE2 represents the resource exchange event of the Layer 1 network whose type of resource processing transaction is data publication; Sig is the signature of Tx2 by the sequencer node using its private key.

[0217] In addition, the ordering node obtains the resource unit consumption of the current block BLOB space from the first-level node. The resource unit consumption of the current block BLOB space can be represented by BaseBlobGasPrice, which represents the resource unit consumption required for 1KB of BLOB space. The ordering node can choose a value greater than or equal to BaseBlobGasPrice to populate GasPrice2 in the TYPE2 type resource exchange transaction Tx2.

[0218] The update mechanism for BaseBlobGasPrice can specifically include the following steps: Obtain the resource unit consumption of the BLOB space in the previous block N-1 of the current block N. n-1 The Gas consumed by the BLOB space within block N-1 is the BLOB space. n-1 The maximum gas capacity of a BLOB block is BLOB. gaslimt and the rate of change between each block BLOCGas rate According to BLOB n-1 BLOB gaslimt BLOBGas rate and BaseBlobGasPrice n-1 Determine the BlobBaseGasPrice of the current block N. n .

[0219] The update of BaseGasPrice depends primarily on the gas usage within the BLOB space of the previous block. BLOBGas rate It can be used to measure the rate of change of BlobBaseGasPrice between each block, and can be set at system startup, for example, BLOBGas. rate It can be set to 8. Furthermore, it can be assumed that the gas limit for a block BLOB space is BLOB. gaslimt The ideal gas usage for each BLOB block is BLOB. expect , Generally, the system can change the 2 in the preceding formula to 3, 4 or 5 according to its own needs.

[0220] The BlobBaseGasPrice of block N can be expressed by the following formula (2):

[0221]

[0222] Assuming BLOB gaslimt =30M, meaning that a BLOB block can contain a maximum of 30M of gas, and BLOB expect =15M, meaning that under ideal network conditions, a node can store 15M of BLOB data using Gas. Assuming BLOB... n-1 =30M, much larger than BLOB expect This indicates that the Layer 2 network has a very high storage demand for BLOB space at this time. Therefore, the resource consumption per unit of BLOB space in block N-1 is BaseBlobGasPrice. n-1 Relatively large.

[0223] at this time,

[0224] Then the BlobBaseGasPrice of the current block N n The previous block BlobBaseGasPrice n-1 1.125 times. At this time, the sequence node can understand that the TYPE2 type resource exchange transaction has a large storage requirement for BLOB space, and when publishing the TYPE2 type resource exchange transaction Tx2, it is necessary to increase GasPrice2 in equation (1). And when BLOB n-1 =7.5M, then the BlobBaseGasPrice of the current block N can be calculated. n The previous block BlobBaseGasPrice n-1 0.9375 times.

[0225] This adaptive adjustment mechanism of BaseBlobGasPrice, which determines the resource consumption per unit of BLOB space in the current block based on BLOB space utilization, can be agreed upon by consensus nodes in the blockchain network. Therefore, the adaptive adjustment mechanism of BlobBaseGasPrice can assess the storage needs of the Layer 2 network for BLOB space, allowing different ordered nodes in the Layer 2 network to converge their resource consumption per unit of BLOB space. Furthermore, BlobGas… rate The rate of change of BlobBaseGasPrice between each block can be controlled. rate =8, then the rate of change of BlobBaseGasPrice is -12.5% ​​to 12.5%; if BlobGas rate =16, then the rate of change of BlobBaseGasPrice is -6.25% to 6.25%, which can be achieved by adjusting BlobGas. rate The value of this value can reduce the fluctuation in the resource unit consumption of the BLOB space.

[0226] Through this adaptive adjustment mechanism, different Layer 2 sequencing nodes can quickly and objectively assess the resource unit consumption of a reasonable BLOB space, and have an expected value for the BlobBaseGasPrice of TYPE2 type resource exchange transactions, avoiding large fluctuations in the BlobBaseGasPrice of TYPE2 type resource exchange transactions, thereby preventing excessive resource consumption by nodes in the Layer 2 network.

[0227] Step 603: The second-layer network node generates a resource exchange transaction of type TYPE1.

[0228] The second-layer network nodes can be ordinary nodes in the first-layer network. Specifically, in the first-layer network, the resource exchange object (an ordinary node in the first-layer network) determines the specific smart contract to interact with the blockchain based on its own resource exchange needs. For example, if the resource exchange object wants to generate a resource exchange event with a specific smart contract, it can construct a TYPE1 type resource exchange transaction. The TYPE1 type resource exchange transaction Tx1 can be represented by the following formula (3):

[0229] Tx1=(From1,To1,CallData1,GasPrice1,Type1,Sig1) (3)

[0230] Wherein, From1 is the resource address of the resource exchange object; To1 is the address of the smart contract to be called by the resource exchange object; CallData1 is the call data of the smart contract, that is, a specific function of the smart contract to be called and the parameter values ​​of the function; GasPrice1 is the resource unit consumption of Gas in the resource consumption of the resource processing transaction, indicating the resources consumed by the resource exchange object per unit of Gas resource exchange event. Gas is a unit of measurement on the blockchain, used to measure the computing resources required to perform a specific operation or contract. Each operation, such as sending a resource exchange event, calling a smart contract, executing code in a smart contract, etc., requires a certain amount of Gas. Type1 is a newly added field in the resource exchange event of this embodiment of the disclosure. Here, TYPE1 represents that the type of the resource processing transaction to be processed is a normal Layer 1 network resource exchange event generated by a Layer 1 network node; Sig1 is the signature of Tx1 by the resource exchange object using its private key.

[0231] Both TYPE2 and TYPE1 resource exchange transactions are placed into the pending resource processing transaction set of the blockchain network. In the blockchain, the pending resource processing transaction set can be a collection of all resource processing transactions that have not yet been processed or confirmed; both TYPE2 and TYPE1 resource exchange transactions can be placed into this set.

[0232] Step 604: The block generation node in the first-layer network selects a resource exchange transaction from the TYPE1 type resource exchange transaction to generate a block body.

[0233] In a layer-one network, a block-generating node obtains multiple TYPE1 type resource exchange transactions from the set of pending resource processing transactions. Based on the Gas Price of each TYPE1 type resource exchange transaction, these transactions are sorted from highest to lowest. The nodes are then simulated and executed one by one according to this sorting, obtaining the Gas used by each TYPE1 type resource exchange transaction. These Gas prices are accumulated until the maximum Gas price a block can contain for TYPE1 type resource exchange transactions is approached. Finally, these TYPE1 type resource exchange transactions that a block can contain are packaged into the block body, thus completing the block body. body The construction of other TYPE1 type resource exchange transactions can be reintroduced into the set of pending resource processing transactions.

[0234] Step 605: The block generation node in the first-layer network selects a resource exchange transaction from the TYPE2 type resource exchange transaction to generate temporary storage data.

[0235] In the first-layer network, the block generation node obtains multiple TYPE2 type resource exchange transactions from the set of pending resource processing transactions. It calculates the BLOB resources corresponding to the BLOB space required for each TYPE2 type resource exchange transaction. The TYPE2 type resource exchange transactions are packaged one by one according to the BLOB resources from high to low, and accumulated until the gas limit of a block can be approached. The portion of TYPE2 type resource exchange transactions that a block can contain is packaged into the temporary storage space (BLOB space). The other TYPE2 type resource exchange transactions are placed into the set of pending resource processing transactions.

[0236] In a Layer 1 network, a block-generating node can first obtain TYPE2 type resource exchange transactions from the set of pending resource processing transactions. Further, the block-generating node in the Layer 1 network can calculate the BLOB resource corresponding to each TYPE2 type resource exchange transaction. txfee BLOB txfee =

[0237] SIZE(TxData)*GasPrice2, where SIZE(TxData) calculates the data storage space required for each TYPE2 type resource exchange transaction. Further, the block generation nodes in the first-layer network are configured according to BLOB resources. txfee Starting from the highest to the lowest, resource exchange transactions of type TYPE2 are packaged one by one and accumulated until the gas limit of a block containing resource exchange transactions of type TYPE2 is approached. Then, the resource exchange transactions of type TYPE2 that a block can contain are packaged into temporary storage space (BLOB space), thus completing the block BLOB space. blob The construction of the resource exchange transaction is then completed. Other TYPE2 type resource exchange transactions are placed into the set of pending resource processing transactions.

[0238] Step 606: The block generation node in the first-layer network generates a block based on the block body and temporary storage data.

[0239] Block generation nodes in a layer 1 network generate blocks. body and BLOB space Block blob Subsequently, the block-generating nodes in the first-layer network begin constructing the block header based on the TYPE1 type resource exchange transactions in the block body. For example, they fill in information such as the block height in the block header to obtain the block header. header The completed block can then be represented by the following formula (4):

[0240] Block = (Block) headerBlock body Block blob (4)

[0241] like Figure 7 The diagram illustrates a block generation process provided in this disclosure. A second-layer network node in the first-layer network generates a normal first-layer network resource exchange event (TYPE1 type resource exchange transaction). The second-layer network node generates a resource exchange event, executes the second-layer network resource exchange event, and sends the data of the second-layer network resource exchange event to the second-layer network ordering node. The second-layer network ordering node compresses and packages the second-layer network resource exchange event data and sends it to the first-layer network node, which then generates a data publishing type first-layer network resource exchange event (TYPE2 type resource exchange transaction) based on a smart contract. The block generation node in the first-layer network packages the TYPE1 type resource exchange transactions that a block can contain into the block body. The block generation node in the first-layer network packages the TYPE2 type resource exchange transactions that a block can contain into the BLOB space. Finally, the block generation node in the first-layer network generates a block based on the block body, block header, and BLOB space.

[0242] Step 607: The block generation node in the first-layer network sends the generated block to the consensus node in the first-layer network for verification.

[0243] In a Layer 1 network, the block-generating node sends the generated block to the consensus node for verification. After generating a block, the block-generating node sends the new block to other nodes in the Layer 1 network, which can be ordinary full nodes or specific consensus nodes. Upon receiving the new block, the consensus node in the Layer 1 network verifies its validity according to the blockchain's rules and protocols.

[0244] Step 608: When the consensus node in the first-layer network returns a verification result indicating that consensus has been achieved, the block generation node broadcasts the block to every node in the first-layer network for on-chain processing.

[0245] After a consensus node in the first-layer network verifies a new block, it sends the generated verification result to the first-layer network nodes. When the verification result indicates that consensus has passed, the first-layer network node broadcasts the block to every node in the first-layer network, and each node in the first-layer network accepts the block and adds it to the blockchain.

[0246] Step 609: Nodes in the first-layer network update the world state of the first-layer network based on the block body.

[0247] When the consensus node in a Layer 1 network returns a verification result indicating that consensus has been reached, the Layer 1 network node broadcasts the block to every node in the Layer 1 network and updates the world state of the Layer 1 network based on the block body.

[0248] After the block is verified, this embodiment updates the world state of the first-layer network only based on the resource exchange event data of the first-layer network in the block body. It does not need to package the resource exchange event data of the second-layer network in the temporary storage area into the block body and participate in the update of the world state of the first-layer network, thereby reducing the expansion of the world state of the first-layer network. The decrease in the expansion rate of the world state can reduce the complex scaling requirements of the blockchain, thereby improving the processing efficiency of blockchain transactions.

[0249] Specifically, the packaging node broadcasts the block to the blockchain network for other consensus (verification) nodes to verify. Furthermore, when each node in the first-layer network receives a block, it can first... header After performing routine checks, each node in the first-layer network will check and execute the block. body For each TYPE1 type resource exchange transaction, ensure the legality of the TYPE1 type resource exchange transaction.

[0250] As for Block blob For each TYPE2 type resource exchange transaction within the block, each node obtains the BaseBlobGasPrice of the current block and then verifies the block. blob For every TYPE2 type resource exchange transaction within the block, the GasPrice2 is greater than BaseBlobGasPrice. TYPE2 type resource exchange transactions with a GasPrice2 less than GasPrice2 are removed. blob The remaining content is a Block. filterblob .

[0251] Step 610: When the time elapsed since the block was generated reaches a preset duration, the nodes in the first-layer network delete the temporary storage data in the block.

[0252] Each node in a layer 1 network can block filterblob The data is stored for a set period, such as 14 days. When the time remaining since the block creation time reaches the preset duration, for example, 14 days, each node in the first-layer network decides whether to continue storing the TYPE2 type resource exchange transactions stored in the BLOB space. For example, each node in the first-layer network can choose to discard the TYPE2 type resource exchange transactions stored in the BLOB space, or it can choose to continue storing the TYPE2 type resource exchange transactions stored in the BLOB space.

[0253] Because many Layer 2 networks require a 14-day period for fraud proof, if a node in the Layer 2 network engages in malicious activity within 14 days, it needs to retrieve TYPE2 type resource exchange transaction data from the Layer 1 network and perform fraud proof. The state of the Layer 2 network after 14 days is deterministic, with no possibility of rollback. Therefore, each node in the Layer 1 network can store TYPE2 type resource exchange transaction data in its BLOB space for up to 14 days. Since the BLOB space is only stored in the Layer 1 network nodes for 14 days, it does not consume too much node storage resources, thus improving the processing efficiency of blockchain transactions. Because the BLOB space does not consume too much node storage resources, the resource consumption required for storing the BLOB space is relatively small; that is, the resource consumption of TYPE2 type resource exchange transactions is small, and the resource consumption distributed among each Layer 2 network resource exchange object is also small.

[0254] Description of apparatus and devices according to embodiments of this disclosure

[0255] It is understood that although the steps in the above flowcharts are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated in this embodiment, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the above flowcharts may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.

[0256] It should be noted that in the various specific embodiments of this disclosure, when processing is required based on data related to the characteristics of the target object, such as target object attribute information or a set of attribute information, the permission or consent of the target object will be obtained first. Furthermore, the collection, use, and processing of this data will comply with the relevant laws, regulations, and standards of the relevant regions. In addition, when this application embodiment needs to obtain target object attribute information, separate permission or consent from the target object will be obtained through pop-up windows or redirection to a confirmation page. Only after obtaining the target object's separate permission or consent will the necessary target object-related data for the normal operation of this application embodiment be obtained.

[0257] Figure 8This is a schematic diagram of the structure of a blockchain transaction processing device 800 provided in an embodiment of this disclosure. The device is applied to a first-layer network node in a preset blockchain network. The preset blockchain network includes a first-layer network and a second-layer network. The first-layer network node is a node that generates blocks in the first-layer network. The device includes:

[0258] The acquisition unit 810 is used to acquire multiple first resource processing transactions to be processed and multiple second resource processing transactions to be processed from the set of pending resource processing transactions. The first resource processing transactions are resource processing transactions generated based on resource exchange events between nodes in the first-layer network, and the second resource processing transactions are resource processing transactions generated based on resource exchange events between nodes in the second-layer network.

[0259] The first generation unit 820 is used to generate a block body based on multiple pending first resource processing transactions;

[0260] The second generation unit 830 is used to generate temporary storage data based on multiple pending second resource processing transactions;

[0261] The third generation unit 840 is used to generate a first target block based on the block body and temporary storage data, and send the first target block to the consensus node in the first layer network for verification.

[0262] The update unit 850 is used to broadcast the first target block to every node in the first layer network when the verification result returned by the consensus node determines that the first target block has passed the verification, and to update the world state of the first layer network based on the block body.

[0263] Optionally, in some embodiments, the third generating unit includes:

[0264] A sub-unit is constructed to build the block structure of the first target block. The block structure includes a block header storage area, a block body storage area, and a temporary storage area.

[0265] The storage sub-unit is used to store temporary storage data in the temporary storage area and store block bodies in the block body storage area.

[0266] The first generation subunit is used to generate block header data based on multiple pending first resource processing transactions in the block body, store the block header data in the block header storage area, and obtain the first target block.

[0267] The sending subunit is used to send the first target block to the consensus node in the first-layer network for verification.

[0268] Optionally, in some embodiments, the first generating subunit includes:

[0269] The first calculation module is used to calculate the hash value of each pending first resource processing transaction in the block body;

[0270] The second calculation module is used to calculate the Merkle root based on the hash value and store the Merkle root in the block header storage area.

[0271] Optionally, in some embodiments, after the update unit, the blockchain transaction processing apparatus provided in this disclosure further includes:

[0272] Add unit, used to add the first target block to the target blockchain;

[0273] The determining unit is used to identify the pending blocks of temporary storage data to be deleted in the target blockchain.

[0274] The deletion unit is used to delete temporary storage data stored in the block to be processed.

[0275] Optionally, in some embodiments, the determining unit includes:

[0276] The first acquisition subunit is used to acquire the first timestamp of each block in the target blockchain;

[0277] The first determining subunit is used to determine the block to be processed containing temporary storage data to be deleted based on the time difference between the first timestamp and the second timestamp of the first target block.

[0278] Optionally, in some embodiments, the determining unit further includes:

[0279] The second acquisition subunit is used to acquire the first block height value of each block in the target blockchain;

[0280] The second determining subunit is used to determine the block to be processed for the temporary storage data to be deleted based on the block height difference between the first block height value and the second block height value of the first target block.

[0281] Optionally, in some embodiments, the first generating unit includes:

[0282] The first sorting subunit is used to sort multiple pending first resource processing transactions according to the first resource unit consumption of each pending first resource processing transaction to obtain a sequence of first resource processing transactions.

[0283] The calculation subunit is used to calculate the first resource consumption corresponding to each first resource processing transaction based on the first resource unit consumption.

[0284] The third determining subunit is used to determine the first target resource processing transaction in the first resource processing transaction sequence based on the first preset total resource amount and the first resource consumption amount corresponding to the first target block.

[0285] The second generation subunit is used to generate a block body based on the transaction processing of the first target resource.

[0286] Optionally, in some embodiments, the third determining subunit includes:

[0287] The accumulation module is used to accumulate the corresponding first resource consumption based on the sorting order of the first resource processing transactions in the first resource processing transaction sequence, so as to obtain the cumulative value of resource consumption.

[0288] The determination module is used to determine the first resource processing transaction that is ranked before the critical resource processing transaction corresponding to the cumulative resource consumption value when the cumulative resource consumption value is greater than the first preset total resource amount.

[0289] Optionally, in some embodiments, the second generating unit includes:

[0290] The second sorting subunit is used to sort multiple pending second resource processing transactions according to the second resource consumption corresponding to each pending second resource processing transaction, so as to obtain a second resource processing transaction sequence.

[0291] The fourth determining subunit is used to determine the second target resource processing transaction in the second resource processing transaction sequence based on the second preset total resource amount and the second resource consumption of the first target block;

[0292] The third generation subunit is used to generate temporary storage data based on the transaction processing of the second target resource.

[0293] Optionally, in some embodiments, the calculation process for the second resource consumption of each pending second resource processing transaction specifically includes the following steps:

[0294] Obtain the data storage space usage and second resource unit consumption for each pending second resource processing transaction;

[0295] The consumption of the second resource is calculated based on the data storage space occupied and the consumption of the second resource unit.

[0296] Optionally, in some embodiments, the method for determining the second resource unit consumption of the first target block specifically includes the following steps:

[0297] Obtain the third resource unit consumption, resource usage, third preset total resource amount, and resource change rate of the second target block. The second target block is the block preceding the first target block.

[0298] The target change factor is obtained by numerically processing the resource usage, the third preset total resource amount, and the resource change rate.

[0299] The second resource consumption of the first target block is determined based on the third resource unit consumption and the target change factor.

[0300] Reference Figure 9 , Figure 9 To illustrate the structural block diagram of a portion of the terminal 140 implementing the blockchain transaction processing method of this embodiment, the terminal 140 includes: a radio frequency (RF) circuit 910, a memory 911, an input unit 930, a display unit 940, a sensor 950, an audio circuit 960, a wireless fidelity (WiFi) module 970, a processor 980, and a power supply 990, among other components. Those skilled in the art will understand that... Figure 9 The terminal 140 structure shown does not constitute a limitation on a mobile phone or computer, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0301] The RF circuit 910 can be used to receive and transmit signals during information transmission or calls. In particular, it receives downlink information from the base station and processes it with the processor 980; in addition, it transmits uplink data to the base station.

[0302] The memory 911 can be used to store software programs and modules. The processor 980 executes various functional applications of the terminal and blockchain transaction processing by running the software programs and modules stored in the memory 911.

[0303] The input unit 930 can be used to receive input numeric or character information, and to generate key signal inputs related to the terminal's settings and function control. Specifically, the input unit 930 may include a touch panel 931 and other input devices 932.

[0304] The display unit 940 can be used to display input or provided information, as well as various menus of the terminal. The display unit 940 may include a display panel 941.

[0305] Audio circuitry 960, speaker 961, and microphone 962 provide an audio interface.

[0306] In this embodiment, the processor 980 included in the terminal 140 can execute the blockchain transaction processing method of the previous embodiment.

[0307] The terminal 140 in this disclosure includes, but is not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc.

[0308] Figure 10This is a partial structural block diagram of a server 110 implementing the blockchain transaction processing method of this disclosure. The server 110 can vary significantly due to different configurations or performance, and may include one or more central processing units (CPUs) 1022 (e.g., one or more processors) and storage devices 1032, and one or more storage media 1030 (e.g., one or more mass storage devices) for storing application programs 1042 or data 1044. The storage devices 1032 and storage media 1030 can be temporary or persistent storage. The program stored in the storage media 1030 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the server 110. Furthermore, the CPU 1022 may be configured to communicate with the storage media 1030 and execute the series of instruction operations in the storage media 1030 on the server 110.

[0309] Server 110 may also include one or more power supplies 1026, one or more wired or wireless network interfaces 1050, one or more input / output interfaces 1058, and / or one or more operating systems 1041, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0310] The central processing unit 1022 in server 110 can be used to execute the blockchain transaction processing method of the present disclosure embodiments.

[0311] This disclosure also provides a storage medium for storing program code, which is used to execute the blockchain transaction processing methods of the foregoing embodiments.

[0312] This disclosure also provides a computer program product comprising a computer program. A processor of a computer device reads and executes the computer program, causing the computer device to perform the blockchain transaction processing method described above.

[0313] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in this disclosure and the foregoing drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “including,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatuses.

[0314] It should be understood that in this disclosure, "at least one item" means one or more, and "more than one" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0315] It should be understood that in the description of the embodiments disclosed herein, "multiple" means two or more, "greater than", "less than", "exceeding" etc. are understood to exclude the number itself, and "above", "below", "within" etc. are understood to include the number itself.

[0316] In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between apparatuses or units, and may be electrical, mechanical, or other forms.

[0317] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0318] Furthermore, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0319] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0320] It should also be understood that the various implementation methods provided in this disclosure can be combined arbitrarily to achieve different technical effects.

[0321] The above is a detailed description of the embodiments of this disclosure. However, this disclosure is not limited to the above embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this disclosure. All such equivalent modifications or substitutions are included within the scope defined by the claims of this disclosure.

Claims

1. A blockchain transaction processing method, characterized by, The method is applied to a layer network node of a preset blockchain network, the preset blockchain network includes a layer network and a two-layer network, the layer network node is a node in the layer network for generating blocks, and the method includes: obtaining a plurality of first resource processing transactions to be processed and a plurality of second resource processing transactions to be processed from a set of transaction processing resources to be processed, the first resource processing transaction is a resource processing transaction generated according to a resource exchange event between nodes in the layer network, and the second resource processing transaction is a resource processing transaction generated based on a resource exchange event between nodes in the two-layer network; generating a block body based on the plurality of first resource processing transactions to be processed; generating temporary storage data based on the plurality of second resource processing transactions to be processed; generating a first target block according to the block body and the temporary storage data, and sending the first target block to a consensus node in the layer network for verification; when it is determined that the first target block passes the verification based on the verification result returned by the consensus node, broadcast the first target block to each node in the layer network, and update the world state of the layer network based on the block body.

2. The method of claim 1, wherein, The first target block is generated according to the block body and the temporary storage data, and the first target block is sent to the consensus node in the layer network for verification, comprising: constructing a block structure of the first target block, the block structure comprising a block header storage area, a block body storage area and a temporary storage area; store the temporary storage data to the temporary storage area, and store the block body to the block body storage area; generate block header data according to the plurality of first resource processing transactions to be processed in the block body, store the block header data to the block header storage area to obtain the first target block; send the first target block to the consensus node in the layer network for verification.

3. The method of claim 2, wherein, The block header data is generated according to the plurality of first resource processing transactions to be processed in the block body, and the block header data is stored in the block header storage area, comprising: calculating the hash value of each first resource processing transaction to be processed in the block body; calculate the Merkle root according to the hash value, and store the Merkle root in the block header storage area.

4. The method of claim 1, wherein, When it is determined that the first target block passes the verification based on the verification result returned by the consensus node, the first target block is broadcast to each node in the layer network, and the world state of the layer network is updated based on the block body, and further comprising: add the first target block to the target block chain; determine a to-be-deleted temporary storage data to-be-processed block in the target block chain; delete the temporary storage data stored in the to-be-processed block.

5. The method of claim 4, wherein, The to-be-deleted temporary storage data to-be-processed block in the target block chain is determined, comprising: obtain the first timestamp of each block in the target block chain; determine the to-be-deleted temporary storage data to-be-processed block based on the time difference value between the first timestamp and the second timestamp of the first target block.

6. The method of claim 4, wherein, The to-be-processed block in which the temporary storage data to be deleted is determined in the target blockchain further includes: Obtaining a first block height value of each block in the target blockchain; Based on the block height difference value between the first block height value and the second block height value of the first target block, determine the to-be-processed block in which the temporary storage data to be deleted.

7. The method of claim 1, wherein, The generation of the block body based on the plurality of to-be-processed first resource processing transactions includes: According to the first resource unit consumption of each to-be-processed first resource processing transaction, the plurality of to-be-processed first resource processing transactions are sorted to obtain a first resource processing transaction sequence; Based on the first resource unit consumption, the first resource consumption corresponding to each first resource processing transaction is calculated; Based on the first preset total amount of resources corresponding to the first target block and the first resource consumption, the first target resource processing transaction is determined in the first resource processing transaction sequence. Based on the first target resource processing transaction, a block body is generated.

8. The method of claim 7, wherein, The determination of the first target resource processing transaction based on the first preset total amount of resources corresponding to the first target block and the first resource consumption in the first resource processing transaction sequence includes: Based on the sorting order of the first resource processing transaction in the first resource processing transaction sequence, the corresponding first resource consumption is accumulated to obtain a resource consumption cumulative value; When the resource consumption cumulative value is greater than the first preset total amount of resources, the first resource processing transaction before the critical resource processing transaction corresponding to the resource consumption cumulative value is determined as the first target resource processing transaction.

9. The method of claim 1, wherein, The generation of the temporary storage data based on the plurality of to-be-processed second resource processing transactions includes: According to the second resource consumption corresponding to each to-be-processed second resource processing transaction, the plurality of to-be-processed second resource processing transactions are sorted to obtain a second resource processing transaction sequence; Based on the second preset total amount of resources of the first target block and the second resource consumption, a second target resource processing transaction is determined in the second resource processing transaction sequence. Based on the second target resource processing transaction, the temporary storage data is generated.

10. The method of claim 9, wherein, The calculation process of the second resource consumption of each to-be-processed second resource processing transaction includes the following steps: Obtaining the data storage space occupation and the second resource unit consumption of each to-be-processed second resource processing transaction; According to the data storage space occupation and the second resource unit consumption, the second resource consumption is calculated.

11. The method of claim 9, wherein, The determination method of the second resource unit consumption of the first target block includes the following steps: Obtaining the third resource unit consumption, resource usage, third preset total amount of resources and resource change rate of the second target block, the second target block is the last block of the first target block; According to the resource usage, the third preset total amount of resources and the resource change rate, a target change multiple is obtained by numerical processing; Based on the third resource unit consumption and the target change multiple, the second resource consumption of the first target block is determined. 12.A blockchain transaction processing apparatus characterized by comprising: The device is applied to a layer network node of a preset blockchain network, the preset blockchain network includes a layer network and a two-layer network, the layer network node is a node in the layer network for block generation, and the device includes: An acquisition unit is configured to acquire a plurality of first resource processing transactions to be processed and a plurality of second resource processing transactions to be processed from a set of resource processing transactions to be processed, the first resource processing transaction is a resource processing transaction generated according to a resource exchange event between nodes in the layer network, and the second resource processing transaction is a resource processing transaction generated based on a resource exchange event between nodes in the two-layer network; A first generation unit is configured to generate a block body based on the plurality of first resource processing transactions to be processed; A second generation unit is configured to generate temporary storage data based on the plurality of second resource processing transactions to be processed; A third generation unit is configured to generate a first target block according to the block body and the temporary storage data, and send the first target block to a consensus node in the layer network for verification; An update unit is configured to broadcast the first target block to each node in the layer network when it is determined that the first target block passes the verification based on a verification result returned by the consensus node, and update a world state of the layer network based on the block body.

13. A storage medium storing a computer program, characterized in that, The computer program is executed by the processor to implement the blockchain transaction processing method according to any one of claims 1 to 11.

14. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to implement the blockchain transaction processing method according to any one of claims 1 to 11.

15. A computer program product, comprising a computer program, the computer program being read and executed by a processor of a computer device, so that the computer device executes the blockchain transaction processing method according to any one of claims 1 to 11.