Block generation method and apparatus
By merging the block formation and pre-execution processes of blockchain nodes, it ensures that transactions rely on correct block information for packaging, thus solving the blockchain fork problem caused by the independence of the pre-execution and block formation processes of blockchain nodes, and achieving consistency and reliability of transaction execution results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ANT BLOCKCHAIN TECHNOLOGY (SHANGHAI) CO LTD
- Filing Date
- 2022-12-30
- Publication Date
- 2026-06-12
AI Technical Summary
In existing technologies, when blockchain nodes operate independently of the pre-execution process and the block formation process, the actual execution result of a transaction may differ from the pre-execution result, potentially causing a blockchain fork.
By bringing the transaction block formation process forward and merging the block formation process with the pre-execution process, the caching process determines whether the block information is consistent. If they are inconsistent, it triggers a re-execution of the transaction, ensuring that the transaction depends on the correct block information for packaging.
This effectively avoids blockchain forks, ensures that the actual execution result of a transaction is consistent with the pre-execution result, and improves the reliability and consistency of the blockchain network.
Smart Images

Figure CN116204335B_ABST
Abstract
Description
Technical Field
[0001] The embodiments in this specification belong to the field of blockchain technology, and in particular relate to a block generation method and apparatus. Background Technology
[0002] Blockchain is a novel application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and cryptographic algorithms. In a blockchain system, data blocks are sequentially linked to form a chain-like data structure, and a distributed ledger is cryptographically guaranteed to be immutable and unforgeable. Users can participate in blockchain-related transactions through blockchain nodes. For example, multiple blockchain nodes corresponding to different users can perform secure multi-party computation (SMPC) on the private data of a particular node based on privacy technologies such as homomorphic encryption and zero-knowledge proofs.
[0003] Currently, before packaging transactions into a block, blockchain nodes typically pre-execute them and obtain pre-execution read / write sets and other results. This allows them to group and execute transactions within the block based on these results after packaging. Some transactions' pre-execution or execution processes rely on the block information of the block they belong to.
[0004] In related technologies, transactions are typically packaged into blocks (or formed into blocks) during the consensus process after pre-execution is complete. At this point, the pre-execution process and the block formation process are two independent processes. Because pre-execution takes time, some transactions that rely on the block information being packaged may not be included in the block after pre-execution. If these transactions are executed based on the block information of the block currently containing them, the actual execution result of these transactions will differ from their pre-execution result, potentially leading to grouping errors and causing a blockchain fork. Summary of the Invention
[0005] The purpose of this invention is to provide a block generation method, node, and blockchain system.
[0006] In a first aspect, a block generation method is provided, applied to the first node in a blockchain network, the first node comprising a caching process and a pre-execution process, the method comprising:
[0007] The pre-execution process relies on the block information of the block being packaged to pre-execute the first transaction, and sends the pre-executed first transaction to the cache process;
[0008] The caching process determines the block information that the first transaction depends on during its pre-execution process, and determines the first block information of the current block that it is currently packaging.
[0009] When the block information is the first block information, the caching process packages the first transaction into the current block;
[0010] When the block information is a second block information that is different from the first block information, the caching process triggers the pre-execution process to re-pre-execute the first transaction based on the first block information.
[0011] Secondly, another block generation method is provided, applied to the first node in a blockchain network, the first node comprising a caching process and a pre-execution process, the method comprising:
[0012] The pre-execution process relies on the block information of the block being packaged to pre-execute at least a portion of the transactions in the transaction group, and sends the pre-executed at least a portion of the transactions to the caching process;
[0013] The caching process determines the block information that at least some of the transactions depend on during the pre-execution process, and determines the first block information of the current block that it is currently packaging.
[0014] When the block information is the first block information, the caching process packages at least a portion of the transactions into the current block;
[0015] When the block information is a second block information that is different from the first block information, the caching process triggers the pre-execution process to re-pre-execute at least some of the transactions based on the first block information.
[0016] Thirdly, a block generation device is provided, applied to a first node in a blockchain network, the first node comprising a caching process and a pre-execution process, the device comprising:
[0017] The pre-execution unit is used to enable the pre-execution process to pre-execute the first transaction based on the block information of the block being packaged, and to send the pre-executed first transaction to the cache process;
[0018] The information determination unit is used to enable the caching process to determine the block information that the first transaction depends on during the pre-execution process, and to determine the first block information of the current block that it is currently packaging.
[0019] A transaction packaging unit is used to enable the caching process to package the first transaction into the current block when the block information is the first block information;
[0020] The re-pre-execution unit is used to enable the cache process to trigger the pre-execution process to re-pre-execute the first transaction based on the first block information when the block information is a second block information that is different from the first block information.
[0021] Fourthly, another block generation device is provided, applied to the first node in a blockchain network. The first node includes a caching process and a pre-execution process. The device includes:
[0022] A pre-execution unit is configured to enable the pre-execution process to pre-execute at least a portion of the transactions in the transaction group based on the block information of the block being packaged, and to send the pre-executed at least a portion of the transactions to the cache process;
[0023] An information determination unit is used to enable the caching process to determine the block information that the at least part of the transactions depend on during the pre-execution process, and to determine the first block information of the current block that it is currently packaging.
[0024] A transaction packaging unit is used to enable the caching process to package at least a portion of the transactions into the current block when the block information is the first block information;
[0025] The re-pre-execution unit is used to enable the caching process to trigger the pre-execution process to re-pre-execute at least some of the transactions based on the first block information when the block information is a second block information that is different from the first block information.
[0026] According to a fourth aspect of one or more embodiments of this specification, an electronic device is provided, comprising:
[0027] processor;
[0028] Memory used to store processor-executable instructions;
[0029] The processor implements the method as described in any one of the first or second aspects by executing the executable instructions.
[0030] According to a fifth aspect of one or more embodiments of this specification, a computer-readable storage medium is provided that stores computer instructions thereon, which, when executed by a processor, implement the steps of the method as described in any one of the first or second aspects.
[0031] Through the above embodiments, the pre-execution process in the first node can pre-execute the first transaction based on the block information of the block being packaged, and send the pre-executed first transaction to the caching process. The caching process receiving the first transaction can obtain the block information that the transaction depends on during execution, and determine the first block information of the current block it is currently packaging; then it determines whether the block information and the first block information are the same: if they are the same, the first transaction is packaged into the current block; otherwise, the pre-execution process is triggered to re-pre-execute the first transaction based on the first block information.
[0032] As can be seen, this scheme advances the block formation process of transactions, merging the block formation process with the pre-execution process. This allows the block formation status of any transaction to influence its pre-execution process. Since the pre-execution process of the first transaction depends on the block information, and the caching process is currently packaging the current block, if the block information is a second block information distinct from the first block information, it indicates that the pre-execution process of the first transaction does not depend on the first block information of the current block. If the first transaction is forcibly packaged into the current block, the execution result obtained by the node relying on the block information (i.e., the first block information) after the block passes consensus will differ from its pre-execution result, potentially causing a blockchain fork. Conversely, if the block information is the first block information of the current block, it indicates that the pre-execution process of the first transaction depends on the first block information. In this case, packaging the first transaction into the current block ensures that after the block passes consensus, the node can rely on the first block information to actually execute the first transaction, thus obtaining the same execution result as the pre-execution result, effectively avoiding blockchain forks. Attached Figure Description
[0033] To more clearly illustrate the technical solutions of the embodiments in this specification, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 This is a schematic diagram of the structure of any two nodes in a blockchain system provided as an exemplary embodiment.
[0035] Figure 2 This is a flowchart of a block generation method provided in an exemplary embodiment.
[0036] Figure 3 This is a flowchart of another block generation method provided in an exemplary embodiment.
[0037] Figure 4 This is a schematic diagram of the structure of a device provided in an exemplary embodiment.
[0038] Figure 5 This is a block diagram of a block generation apparatus provided in an exemplary embodiment.
[0039] Figure 6 This is a block diagram of another block generation apparatus provided in an exemplary embodiment. Detailed Implementation
[0040] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.
[0041] A blockchain system establishes a distributed network through multiple nodes, where any two nodes communicate at the application layer via a peer-to-peer (P2P) network. The blockchain system utilizes a chained block structure to construct a decentralized (or multi-centralized) distributed ledger, which is stored on each node (or most nodes, such as consensus nodes) within the distributed blockchain system. Therefore, the blockchain system needs to address the issue of consistency and correctness of the ledger data across multiple decentralized (or multi-centralized) nodes. Accordingly, each node in the blockchain system runs a blockchain program. With certain fault tolerance requirements, a consensus mechanism ensures that all loyal nodes have the same transactions, thereby guaranteeing consistent execution results for the same transactions. Transactions are packaged into blocks, and the world state is updated based on the execution results of the same transactions. The current mainstream consensus mechanisms include, but are not limited to: Proof of Work (POW), Proof of Stake (POS), Practical Byzantine Fault Tolerance (PBFT) algorithm, Honey Badger Byzantine Fault Tolerance (HoneyBadgerBFT) algorithm, etc.
[0042] As mentioned earlier, in related technologies, if the pre-execution process of a transaction depends on the block information of block B1, and the transaction is subsequently packaged into block B2 (i.e., not packaged into block B1), then after block B2 passes consensus, when the blockchain nodes in the blockchain network execute the above transaction, the actual execution result of the transaction will be different from its pre-execution result, which may lead to a fork in the blockchain.
[0043] To address the aforementioned problems in related technologies, this specification proposes a block generation method. By advancing the transaction packaging process to the pre-execution process and comparing block information to achieve re-pre-execution of transactions, this method ensures that transactions pre-executed based on the block information of any given block can be accurately packaged into that block. This guarantees that the actual execution result of a transaction is identical to its pre-execution result, effectively preventing blockchain forks. The block generation method is described in detail below with reference to the accompanying drawings.
[0044] The block generation method described in this specification is applied to the first node in a blockchain network. The first node can be any node in the blockchain network, and this node can be implemented as a device, platform, equipment, or cluster of devices with computing / processing capabilities. Firstly, in conjunction with... Figure 1 This section introduces the various processes contained in the first node. Figure 1 This is a schematic diagram of the structure of any two nodes in a blockchain system provided as an exemplary embodiment.
[0045] like Figure 1 As shown, any two nodes n1 and n2 in the blockchain network each contain multiple processes to provide various services. For example, nodes n1 and n2 each contain access processes for providing access services to the blockchain network (such as access process 1 in node n1 and access process 2 in node n2; the meanings of other process numbers are similar and will not be repeated). They also contain caching processes for providing caching services, pre-execution processes for providing pre-execution services, network processes for providing network services, consensus processes for providing consensus services, control processes for providing block management services, and storage processes for providing storage services. Let's assume that nodes n1 and n2 are the slave node and master node in the blockchain network, respectively. In this case, node n1 can also contain multiple computing processes for providing computing services, such as computing process 11, computing process 12, and computing process 13. Currently, node n2 can also contain at least one computing process for executing transactions contained in blocks that have passed consensus; this will not be elaborated further.
[0046] In this specification, a process refers to a running activity of a program with a certain independent function in an application regarding a data set. That is, a process is a procedure in a computer performed by the CPU sequentially executing instructions in an application, and each process is allocated its own memory address space upon creation. Multiple processes in any node can be multiple processes in multiple computing devices or virtual computing nodes. Furthermore, it should be noted that the solutions provided in the embodiments of this specification are not limited to master-slave blockchain systems; in other words, node n1 and node n2 in this solution can be any two blockchain nodes in the blockchain system.
[0047] Figure 2 This is a flowchart illustrating a block generation method provided in an exemplary embodiment. For example... Figure 2 As shown, this method is applied to the first node in a blockchain network, which includes a caching process and a pre-execution process. As previously mentioned, the first node can be any node in the blockchain network, such as... Figure 1 The node n1 or node n2 shown. The method includes the following steps 202-206b.
[0048] Step 202: The pre-execution process pre-executes the first transaction based on the block information of the block being packaged, and sends the pre-executed first transaction to the cache process.
[0049] The caching process in the first node can be used to maintain the pending transactions (e.g., transactions to be packaged) received by that node, that is, to cache the transactions locally on the first node. For example, the caching process can record each transaction received by the first node in its own queue of pending transactions. Exemplarily, the caching process can record each transaction in the transaction queue sequentially according to the order of their initiation time (i.e., the time when the transaction initiator initiates the transaction) or according to the order of the first node's receipt time (i.e., the time when the first node receives the transaction), so that the transactions can be processed sequentially in the following order. The first transaction in this scheme can be any transaction maintained by the caching process.
[0050] Each transaction in the message queue needs to undergo pre-execution processing before being packaged. Therefore, the caching process needs to send each transaction to the pre-execution process. Some or all of the transactions in the transaction queue may need to rely on block information during pre-execution; that is, the pre-execution process may need to rely on block information to pre-execute certain transactions. To address this, the caching process can send the transactions to be packaged to the pre-execution process using a multi-pass method.
[0051] In one embodiment, the caching process may send transactions only to the pre-execution process. For example, each transaction in the transaction queue can be sent to the pre-execution process one by one, or multiple consecutive transactions in the transaction queue can be sent to the pre-execution process as a group (hereinafter referred to as a transaction group) at once, thereby reducing the number of interactions with the pre-execution process and improving the transaction transmission efficiency between the two processes. In this case, the pre-execution process only receives transactions from the caching process, so the pre-execution process can also call the block information of the block being packaged (such as the nth block) through a preset API (Application Programming Interface) and pre-execute the first transaction based on this block information. For example, a hook can be added to the hostAPI method so that the pre-execution process can call the block information of the block being packaged by the caching process through the hostAPI.
[0052] In another embodiment, the caching process can associate and send transactions and the block information they depend on to the pre-execution process. For example, before sending the first transaction, the caching process can determine whether the transaction needs to depend on block information during the pre-execution process. If it is determined that the first transaction needs to depend on block information, the caching process associates the first transaction with the block information of the block that the caching process is currently packaging (e.g., block n) and sends it to the pre-execution process. Alternatively, to improve transaction transmission efficiency and the number of block information transmissions, before sending the transaction group, the caching process can first determine whether the transaction group contains transactions that the pre-execution process needs to depend on block information. If such transactions exist in the transaction group (e.g., such transactions at least include the first transaction), the caching process associates the transaction group with the block information of the block that the caching process is currently packaging (e.g., block n) and sends it to the pre-execution process.
[0053] As an exemplary embodiment, the pre-execution process can receive a transaction group sent by the caching process and block information of the block being packaged by the caching process (such as block n), then pre-execute at least a portion of the transactions in the transaction group, including the first transaction, based on the received block information, and send the pre-executed at least a portion of the transactions to the caching process. The at least a portion of the transactions may only include the first transaction (in this case, only the pre-execution process of the first transaction in the transaction group needs to rely on block information). In this case, the pre-execution process only needs to rely on the block information to pre-execute the first transaction and return the executed first transaction to the caching process. Alternatively, the at least a portion of the transactions may include a second transaction in addition to the first transaction—similar to the first transaction, the pre-execution process of the second transaction also needs to rely on block information. Furthermore, the number of second transactions can be one or more, meaning that the second transactions are of the same type of transactions whose pre-execution process relies on block information; obviously, both the first transaction and the second transaction are of this type. Therefore, if the transaction group also contains a second transaction, the pre-execution process can rely on the block information to pre-execute the first transaction and the second transaction respectively, and send the pre-executed first transaction and the second transaction to the cache process.
[0054] Alternatively, the transaction group may include, in addition to the first transaction (or the first and second transactions) that also require block information during pre-execution, a third transaction that does not require any block information during pre-execution. Similarly, the number of third transactions can be one or more, meaning the third transactions are of the same type that do not require any block information during pre-execution. In this case, the pre-execution process can also execute the third transaction without relying on any block information and send the completed third transaction to the caching process. Alternatively, regardless of whether the caching process sends the first transaction to the pre-execution process separately or includes it in a transaction group (along with other transactions), the caching process can also send the third transaction to the pre-execution process—that is, without including the third transaction in the transaction group. In this case, the pre-execution process can also pre-execute these third transactions without relying on any block information and send the completed third transaction to the caching process.
[0055] In this way, the pre-execution process can pre-execute each transaction it receives. For the first and second transactions, since their pre-execution process depends on block information, the caching process needs to further determine whether the block information actually relied upon by their pre-execution process is consistent with the block information of the current block that the caching process is currently packaging. For the third transaction, regardless of whether it is included in the transaction group, the caching process can directly package it into the current block, which will not be elaborated further.
[0056] For the first transaction, the embodiments in this specification involve two types of block information: the block information relied upon by the pre-execution phase and the block information of the current block being processed by the caching process after the first transaction has been pre-executed. These two types of block information may be the same or different. It should be noted that the block information of any block described in the embodiments of this specification may include the block height and / or the block timestamp.
[0057] After receiving the first transaction sent by the caching process and obtaining the block information of the block being packaged by the caching process, the pre-execution process can pre-execute the first transaction based on the block information and send the pre-executed first transaction to the caching process. The aforementioned pre-execution process corresponds to relevant pre-execution information, which may include the block information, the pre-execution result of the first transaction, and the pre-execution read / write set. The pre-execution read / write set may include a pre-execution read set (corresponding to data read operations involved in the transaction execution process) and / or a pre-execution write set (corresponding to data write operations involved in the transaction execution process). The pre-execution process can also associate the pre-execution information with the first transaction and send it to the caching process. Alternatively, if the block information is sent by the caching process to the pre-execution process, the caching process can maintain the correspondence between the first transaction and the block information itself. In this case, the pre-execution process can only return the pre-execution result and / or the pre-execution read / write set to the caching process without returning the block information.
[0058] It should also be noted that in this scheme, the caching process and the pre-execution process in the first node work together to implement the pre-execution and packaging process for the first transaction. Specifically, for multiple pending transactions received by the first node, the caching process, pre-execution process, and consensus process in the first node can cooperate to implement the pre-execution, packaging, consensus, transaction execution, and block writing processes for each transaction in parallel in a pipelined manner (or block pipeline). For example, at any given time, the block pipeline can reach consensus on block 100, execute the transaction in block 99, write block 98, etc., which will not be elaborated further.
[0059] Step 204: The caching process determines the block information that the first transaction depends on during the pre-execution process, and determines the first block information of the current block that it is currently packaging.
[0060] After receiving the first transaction that has been completed from the pre-execution process, the caching process can determine the block information that the transaction depends on during the pre-execution process (i.e., the block information of the block being packaged as determined by the caching process in step 202), and can also determine the first block information of the current block that it is currently packaging.
[0061] In one embodiment, the caching process can determine whether the first transaction is a replay transaction (i.e., detect whether replay attacks exist) according to preset rules. If the first transaction is a replay transaction, the packaging of the first transaction should be terminated, and relevant information of the first transaction should be recorded, and / or an alarm for replay supply should be initiated. Conversely, if the first transaction is not a replay transaction, the subsequent processing of the first transaction can then begin. Of course, the above-mentioned replay attack detection process can also be performed by the caching process when the first transaction is received. For each transaction received by the first node, the caching process can judge it according to the aforementioned preset rules to determine whether it is a replay transaction: if any transaction is a replay transaction, the subsequent processing of the transaction can be terminated, thereby effectively avoiding invalid pre-execution of replay transactions and improving the efficiency of effective pre-execution of the pre-execution process; conversely, if any transaction is not a replay transaction, the subsequent processing of the transaction can then begin (such as recording the transaction in the aforementioned transaction queue, sending the transaction to the pre-execution process for pre-execution, etc.).
[0062] In one embodiment, the caching process can determine the block information relied upon during the pre-execution process of the first transaction in various ways. For example, after the pre-execution process completes the pre-execution of the first transaction relying on the block information, it can associate the block information with the first transaction and send it to the caching process, so that the caching process can determine the information upon receiving the block information. As another example, when sending one or more transactions in the transaction queue and the block information relied upon by their pre-execution processes to the pre-execution process, the caching process can maintain the correspondence between transactions and the block information relied upon by their pre-execution processes. Based on this, upon receiving the first transaction, the caching process can find the block information corresponding to the first transaction according to the correspondence.
[0063] It is understandable that, since the pre-execution process of the first transaction requires a certain amount of time, at the current moment after receiving the first transaction, the current block that the caching process is packaging may be the block corresponding to the block information (i.e., during the pre-execution of the first transaction, the caching process has not yet completed the packaging process for this block), or it may not be the block corresponding to the block information (i.e., during the pre-execution of the first transaction, the caching process has already completed the packaging process for the block corresponding to the block information, and the current block being packaged is another block after the block corresponding to the block information). Based on this, the caching process can determine whether the block information is the first block information: if the block information is the second block information that is different from the first block information (i.e., the block information is not the first block information), then proceed to step 206a; otherwise, if the block information is the first block information, then proceed to step 206b.
[0064] Step 206a: When the block information is a second block information that is different from the first block information, the caching process triggers the pre-execution process to re-pre-execute the first transaction based on the first block information.
[0065] The block information is a second block information distinct from the first block information. This means the block information relied upon by the first transaction pre-execution process is not the first block information, indicating that the block corresponding to the block information has already been packaged (possibly due to the execution time of the first transaction or all transactions in the transaction group being too long). In the blockchain ledger, the current block will be added after the block corresponding to the block information (the interval between the two is determined by their block heights). At this time, the caching process can trigger the pre-execution process to re-pre-execute the first transaction based on the first block information of the current block, so that subsequent attempts can be made to package the first transaction into the current block.
[0066] In one embodiment, the caching process can provide the first block information as context information for the first transaction to the pre-execution process, so that the pre-execution process can re-pre-execute the first transaction based on the first block information. Of course, the caching process can also reset the context information for the first transaction based on the current block, which will not be elaborated further.
[0067] The caching process can trigger the pre-execution process to re-pre-execute the first transaction based on the first block information. Alternatively, if the transaction group to which the first transaction belongs also contains second transactions, the caching process can also trigger the pre-execution process to re-pre-execute both the first transaction and each of the second transactions based on the first block information. This ensures that each transaction requiring pre-execution based on block information can be re-pre-executed by the pre-execution process based on the first block information, thus preparing the data for the caching process to re-attempt packaging these transactions into the current block.
[0068] Alternatively, if the transaction group to which the first transaction belongs also contains a third transaction, the caching process can also trigger the pre-execution process to re-pre-execute all transactions in the transaction group, so that the pre-execution process re-pre-executes the first transaction (or the first transaction and each of the second transactions) based on the first block information, and re-pre-executes each of the third transactions without relying on any block information.
[0069] Step 206b: If the block information is the first block information, the caching process packages the first transaction into the current block.
[0070] The block information refers to the first block information, meaning that the first transaction pre-execution process depends on the first block information. This indicates that the block in which the caching process is packaging the first transaction is the current block information. At this time, the caching process can package the first transaction into the current block.
[0071] As can be seen, this scheme advances the block formation process of transactions, merging the block formation process with the pre-execution process. This allows the block formation status of any transaction to influence its pre-execution process. Since the pre-execution process of the first transaction depends on the block information, and the caching process is currently packaging the current block, if the block information is a second block information distinct from the first block information, it indicates that the pre-execution process of the first transaction does not depend on the first block information of the current block. If the first transaction is forcibly packaged into the current block, the execution result obtained by the node relying on the block information (i.e., the first block information) after the block passes consensus will differ from its pre-execution result, potentially causing a blockchain fork. Conversely, if the block information is the first block information of the current block, it indicates that the pre-execution process of the first transaction depends on the first block information. In this case, packaging the first transaction into the current block ensures that after the block passes consensus, the node can rely on the first block information to actually execute the first transaction, thus obtaining the same execution result as the pre-execution result, effectively avoiding blockchain forks.
[0072] In one embodiment, to ensure a relatively uniform block size, the current block may typically be set with a maximum number of transactions (i.e., the maximum number of transactions that can be included in the block) and / or a maximum transaction data size (i.e., the maximum amount of data that can be included in the block). To address this, the caching process should ensure that the size of the current block after packaging the first transaction does not exceed the maximum number of transactions and / or that the data size of the current block does not exceed the maximum transaction data size when packaging the first transaction into the current block. For example, before packaging the first transaction, the caching process can determine the number of already packaged transactions, i.e., the number of transactions currently packaged into the current block. Then, the caching process can package the first transaction into the current block if the difference between the maximum number of transactions in the current block and the number of already packaged transactions is not less than 1. Alternatively, following the foregoing embodiments, if the first transaction is included in the aforementioned transaction group and the pre-execution process relies on the block information to pre-execute at least some transactions in the transaction group, including the first transaction, then the caching process can package the at least some transactions into the current block, provided that the difference between the maximum number of transactions in the current block and the number of already packaged transactions is not less than the number of the at least some transactions. In this way, at least some transactions, including the first transaction, can be packaged together into the current block, thereby ensuring that the number of transactions packaged in the current block does not exceed its maximum number of transactions, while also ensuring that these transactions pre-executed relying on the same block information (i.e., the block information) are packaged into the same block (i.e., the current block).
[0073] For example, before packaging the first transaction, the caching process can determine the amount of transaction data already packaged, i.e., the amount of transaction data currently packaged into the current block. Then, the caching process can package the first transaction into the current block if the difference between the maximum transaction data size of the current block and the amount of packaged transaction data is not less than the amount of the first transaction. Alternatively, following the aforementioned embodiments, if the first transaction is included in the aforementioned transaction group and the pre-execution process relies on the block information to pre-execute at least some transactions in the transaction group, including the first transaction, then the caching process can package the at least some transactions into the current block if the difference between the maximum transaction data size of the current block and the amount of packaged transaction data is not less than the transaction data size of the at least some transactions. In this way, at least some transactions, including the first transaction, can be packaged together into the current block, thereby ensuring that the amount of transaction data packaged in the current block does not exceed its maximum transaction data size, while ensuring that the transactions pre-executed relying on the same block information (i.e., the block information) are packaged into the same block (i.e., the current block).
[0074] Furthermore, in cases where at least some of the aforementioned transactions comprise multiple transactions, the caching process can sequentially package each transaction into the current block according to the pre-execution order of the multiple transactions. As mentioned earlier, the multiple transactions include each transaction in a transaction group that relies on the same block information (i.e., the block information) for pre-execution. In this way, these transactions can be packaged into the same block (i.e., the current block), so that each node in the blockchain network can execute each transaction according to the aforementioned pre-execution order based on the first block information of the current block information after consensus is reached on this block. This further ensures that the actual execution result of each transaction is the same as its pre-execution result, achieving accurate execution of each transaction and effectively avoiding blockchain forks.
[0075] As mentioned above, the first node may also include a computation process, and the pre-execution process can obtain a corresponding pre-execution read-write set and / or pre-execution result by pre-executing the first transaction. Based on this, the pre-execution process can send the pre-execution read-write set and / or pre-execution result to the cache process; correspondingly, the cache process can trigger the computation process to execute the first transaction and obtain the execution read-write set and / or execution result of the first transaction returned by the computation process. Based on this, if the pre-execution read-write set of the first transaction is the same as the execution read-write set, and / or the pre-execution result of the first transaction is the same as the execution result, the cache process can package the first transaction into the current block.
[0076] In another embodiment, the caching process can further compare the pre-execution read-write set of the first transaction with the pre-execution read-write sets of the preceding transactions (i.e., transactions in the current block preceding the first transaction) that have already been packaged into the current block at the current time, to determine whether the pre-execution read-write set of the first transaction conflicts with the pre-execution read-write sets of some preceding transactions. If such online transactions exist, the first transaction should be avoided from being packaged into the current block (because if the first transaction is forcibly packaged into the current block, there will be read-write set conflicts among the transactions in that block during actual execution, causing errors in transaction execution and on-chain data writing); conversely, if there are no such preceding transactions (i.e., the pre-execution read-write set of the first transaction does not conflict with the pre-execution read-write sets of any preceding transactions), the first transaction can be packaged into the current block.
[0077] This concludes the description of the process of packaging the first transaction into the current block. As mentioned earlier, the caching process can include the first transaction in a transaction group and send it to the pre-execution process, which can then pre-execute (and re-pre-execute) each transaction within the transaction group. This specification also proposes another block generation method.
[0078] Figure 3This is a flowchart illustrating another block generation method provided in an exemplary embodiment. For example... Figure 3 As shown, the method is applied to the first node in a blockchain network, the first node comprising a caching process and a pre-execution process, each comprising steps 302-306b below.
[0079] Step 302: The pre-execution process pre-executes at least a portion of the transactions in the transaction group based on the block information of the block being packaged, and sends the pre-executed at least a portion of the transactions to the caching process.
[0080] Step 304: The caching process determines the block information that the at least part of the transactions depend on during the pre-execution process, and determines the first block information of the current block that it is currently packaging.
[0081] Step 306a: If the block information is a second block information that is different from the first block information, the caching process triggers the pre-execution process to re-pre-execute at least some of the transactions based on the first block information.
[0082] Step 306b: If the block information is the first block information, the caching process packages at least a portion of the transactions into the current block.
[0083] In one embodiment, the transaction group may contain at least one transaction that requires a blockchain network for pre-execution (such as the first transaction mentioned above, or the first and second transactions). In this case, the pre-execution process may rely on the block information of the block being packaged by the caching process to pre-execute all transactions in the transaction group.
[0084] In another embodiment, besides transactions whose pre-execution process relies on block information, the transaction group may also include transactions whose pre-execution process does not require any block information (such as the third transaction mentioned above). In this case, the pre-execution process can rely on the block information of the block being packaged by the caching process to pre-execute some transactions in the transaction group (i.e., transactions whose pre-execution process relies on block information—such as the first transaction, or the first and second transactions). Alternatively, it can pre-execute the remaining transactions in the transaction group (excluding the aforementioned transactions) without relying on any block information (i.e., transactions whose pre-execution process does not require any block information—such as the third transaction), and send the pre-executed remaining transactions to the caching process. Through this process, the pre-execution process can complete the pre-execution of each transaction in the transaction group based on the corresponding data.
[0085] Furthermore, when packaging at least a portion of the transactions into the current block, the caching process can package all transactions in the transaction group into the current block together. Specifically, if the transaction group only contains transactions that require block information for the pre-execution process, the caching process can package all of these transactions into the current block; while if the transaction group contains both transactions that require block information for the pre-execution process and other transactions that do not require block information for the pre-execution process, the caching process can package all transactions (i.e., the aforementioned partial transactions and other transactions) into the current block. This method ensures that all transactions in the same transaction group that require the same block information for pre-execution are accurately packaged into the same block, further ensuring that the actual execution result obtained from actually executing these transactions is the same as its pre-execution result, thus avoiding blockchain forks.
[0086] Additionally, for details regarding the pre-execution and packaging process of some transactions within the transaction group, please refer to [link / reference needed]. Figure 1 The corresponding embodiments will not be described again here.
[0087] Similar to the aforementioned scheme, this scheme advances the block formation process of transactions, merging the block formation process with the pre-execution process. This allows the block formation status of some transactions within a transaction group (whose pre-execution process depends on block information) to influence the pre-execution process of those transactions. Since the pre-execution process of these transactions depends on block information, and the caching process is currently packaging the current block, if the block information is a second block information distinct from the first block information, it indicates that the pre-execution process of these transactions does not depend on the first block information of the current block. If these transactions are forcibly packaged into the current block, after consensus is reached on that block, the execution result obtained by the node actually executing these transactions based on the block information (i.e., the first block information) will differ from the corresponding pre-execution result, potentially causing a blockchain fork. Conversely, if the block information is the first block information of the current block, it means that the pre-execution process of the partial transactions depends on the first block information of the current block. In this case, packaging the partial transactions into the current block can ensure that after the consensus of the block is passed, the node can actually execute the partial transactions based on the first block information, thereby obtaining the same actual execution result as the pre-execution result, which can effectively avoid blockchain forks.
[0088] Figure 4 This is a schematic structural diagram of a device provided in an exemplary embodiment. Please refer to... Figure 4At the hardware level, the device includes a processor 402, an internal bus 404, a network interface 406, memory 408, and non-volatile memory 410, and may also include other hardware required for business operations. One or more embodiments of this specification can be implemented in software, such as the processor 402 reading the corresponding computer program from the non-volatile memory 410 into memory 408 and then running it. Of course, in addition to software implementation, one or more embodiments of this specification do not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0089] like Figure 5 As shown, Figure 5 This is a block diagram of a block generation apparatus provided in this specification according to an exemplary embodiment, which can be applied to, for example... Figure 4 The device shown implements the technical solution of this specification. The device is applied to a first node in a blockchain network, the first node comprising a caching process and a pre-execution process, and the device includes:
[0090] The pre-execution unit 501 is used to enable the pre-execution process to pre-execute the first transaction based on the block information of the block being packaged, and to send the pre-executed first transaction to the cache process;
[0091] The information determination unit 502 is used to enable the caching process to determine the block information that the first transaction depends on during the pre-execution process, and to determine the first block information of the current block that it is currently packaging.
[0092] The re-pre-execution unit 503 is used to enable the cache process to trigger the pre-execution process to re-pre-execute the first transaction based on the first block information when the block information is a second block information that is different from the first block information.
[0093] The transaction packaging unit 504 is used to enable the caching process to package the first transaction into the current block when the block information is the first block information.
[0094] Optionally, the pre-execution unit 501 is further configured to:
[0095] The pre-execution process receives a transaction group sent by the caching process and block information of the block that the caching process is packaging, wherein the transaction group contains at least a first transaction;
[0096] The pre-execution process pre-executes at least some of the transactions in the transaction group, including the first transaction, based on the received block information, and sends the pre-executed at least some of the transactions to the cache process.
[0097] Optionally, the pre-execution unit 501 is further configured to:
[0098] If the pre-execution process includes a second transaction in the transaction group, it pre-executes the first and second transactions respectively based on the block information, and sends the pre-executed first and second transactions to the cache process.
[0099] Optionally, the transaction packaging unit 504 is further configured to:
[0100] If the difference between the maximum number of transactions in the current block and the number of transactions already packaged is not less than the number of transactions in the at least part of the transaction group, the caching process packages the at least part of the transactions into the current block, wherein the number of transactions already packaged is the number of transactions already packaged into the current block at the current moment; and / or;
[0101] If the difference between the maximum transaction data volume of the current block and the already packaged transaction data volume is not less than the data volume of at least some of the transactions in the transaction group, the caching process packages the at least some transactions into the current block, wherein the already packaged transaction data volume is the data volume of transactions already packaged into the current block at the current moment.
[0102] Optionally, when at least some transactions comprise multiple transactions, the transaction packaging unit 504 is further configured to:
[0103] The caching process packages each transaction into the current block in the order of their pre-execution.
[0104] Optionally, the transaction packaging unit 504 is further configured to:
[0105] The pre-execution process invokes the block information of the block being packaged through a preset application programming interface, and pre-executes the first transaction based on the block information.
[0106] Optionally, the information determining unit 502 is further configured to:
[0107] The caching process receives the block information sent by the pre-execution process in association with the first transaction; or,
[0108] The caching process can find the block information corresponding to the first transaction based on the correspondence between the transaction and the block information on which the pre-execution process depends, which it maintains.
[0109] Optionally, the re-pre-execution unit 503 is further configured to:
[0110] The caching process provides the first block information as context information for the first transaction to the pre-execution process, so that the pre-execution process can re-pre-execute the first transaction based on the first block information.
[0111] Optionally, the first node may also contain the computation process.
[0112] The apparatus further includes a result sending unit 505, which enables the pre-execution process to send the pre-execution read / write set and / or pre-execution result of the first transaction to the caching process;
[0113] The transaction packaging unit 504 is further configured to: cause the caching process to trigger the computing process to execute the first transaction, and obtain the execution read-write set and / or execution result of the first transaction returned by the computing process; and, if the pre-execution read-write set of the first transaction is the same as the execution read-write set; and / or the pre-execution result of the first transaction is the same as the execution result, package the first transaction into the current block.
[0114] Optional, also includes:
[0115] The transaction execution unit 506 is used to enable the pre-execution process to pre-execute the third transaction without relying on any block information, and to send the pre-executed third transaction to the cache process;
[0116] The third transaction packaging unit 507 is used to enable the caching process to package the third transaction into the current block.
[0117] Optionally, the block information for any block may include the block height and / or the block timestamp.
[0118] like Figure 6 As shown, Figure 6 This is a block diagram of another block generation apparatus provided in this specification according to an exemplary embodiment, which can be applied to, for example... Figure 4 The device shown implements the technical solution of this specification. The device is applied to a first node in a blockchain network, the first node comprising a caching process and a pre-execution process, and the device includes:
[0119] The pre-execution unit 601 is configured to enable the pre-execution process to pre-execute at least a portion of the transactions in the transaction group based on the block information of the block being packaged, and to send the pre-executed at least a portion of the transactions to the cache process;
[0120] The information determination unit 602 is used to enable the caching process to determine the block information that the at least part of the transactions depend on during the pre-execution process, and to determine the first block information of the current block that it is currently packaging.
[0121] The re-pre-execution unit 603 is used to enable the cache process to trigger the pre-execution process to re-pre-execute at least some of the transactions based on the first block information when the block information is a second block information that is different from the first block information;
[0122] The transaction packaging unit 604 is used to enable the caching process to package at least a portion of the transactions into the current block when the block information is the first block information.
[0123] Optional,
[0124] The pre-execution unit 601 is further configured to: enable the pre-execution process to pre-execute a portion of the transactions in the transaction group based on the block information of the block being packaged;
[0125] The apparatus further includes a pre-execution unit 605 for pre-executing other transactions in the transaction group without relying on any block information, and sending the pre-executed other transactions to the cache process.
[0126] Optionally, the transaction packaging unit 604 is further configured to:
[0127] The caching process then packages all transactions in the transaction group into the current block.
[0128] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0129] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0130] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or physical entities, or by products with certain functions. A typical implementation device is a server system. Of course, this invention does not exclude the possibility that, with the future development of computer technology, the computer implementing the functions of the above embodiments can be, for example, a personal computer, a laptop computer, an in-vehicle human-machine interaction device, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.
[0131] While one or more embodiments of this specification provide the operational steps of the methods described in the embodiments or flowcharts, more or fewer operational steps may be included based on conventional or non-inventive means. The order of steps listed in the embodiments is merely one possible order of execution among many steps and does not represent the only possible order. In actual device or end product execution, the methods shown in the embodiments or drawings may be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment, or even a distributed data processing environment). The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, product, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, product, or apparatus. Without further limitations, the presence of other identical or equivalent elements in the process, method, product, or apparatus that includes the elements is not excluded. For example, the use of terms such as "first," "second," etc., is to denote names and does not indicate any particular order.
[0132] For ease of description, the above devices are described in terms of function, divided into various modules. Of course, when implementing one or more of these specifications, the functions of each module can be implemented in one or more software and / or hardware components, or a module that performs the same function can be implemented by a combination of multiple sub-modules or sub-units. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; 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 devices or units, and may be electrical, mechanical, or other forms.
[0133] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0134] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0135] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0136] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0137] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0138] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0139] Those skilled in the art will understand that one or more embodiments of this specification can be provided as a method, system, or computer program product. Therefore, one or more embodiments of this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0140] One or more embodiments of this specification can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a particular task or implement a particular abstract data type. One or more embodiments of this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can reside in local and remote computer storage media, including storage devices.
[0141] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, system embodiments are basically similar to method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments. In the description of this specification, the terms "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this specification. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described can be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0142] The above description is merely an embodiment of one or more embodiments of this specification and is not intended to limit the scope of this specification. Various modifications and variations can be made to the one or more embodiments of this specification by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims.
Claims
1. A block generation method, applied to a first node in a blockchain network, the first node comprising a caching process and a pre-execution process, the method comprising: The pre-execution process relies on the block information of the block being packaged to pre-execute the first transaction, and sends the pre-executed first transaction to the cache process; The caching process determines the block information that the first transaction depends on during its pre-execution process, and determines the first block information of the current block that it is currently packaging. When the block information is a second block information that is different from the first block information, the caching process triggers the pre-execution process to re-pre-execute the first transaction based on the first block information; If the block information is the first block information, the caching process will package the first transaction into the current block.
2. The method according to claim 1, wherein the pre-execution process pre-executes a first transaction based on the block information of the block being packaged, and sends the pre-executed first transaction to the caching process, comprising: The pre-execution process receives a transaction group and block information of the block being packaged by the caching process from the caching process, wherein the transaction group contains at least a first transaction; The pre-execution process relies on the received block information to pre-execute at least some of the transactions in the transaction group, including the first transaction, and sends the pre-executed at least some of the transactions to the cache process.
3. The method according to claim 2, wherein the pre-execution process pre-executes at least a portion of the transactions in the transaction group, including the first transaction, based on the received block information, comprising: If the transaction group also contains a second transaction, the pre-execution process pre-executes the first and second transactions respectively based on the block information, and sends the pre-executed first and second transactions to the cache process.
4. The method according to claim 2, wherein the caching process packages the first transaction into the current block, comprising: The caching process packages the at least a portion of transactions into the current block if the difference between the maximum number of transactions in the current block and the number of transactions already packaged is not less than the number of transactions in the at least a portion of the transactions in the transaction group, wherein the number of transactions already packaged is the number of transactions already packaged into the current block at the current moment; and / or; If the difference between the maximum transaction data volume of the current block and the already packaged transaction data volume is not less than the data volume of at least some of the transactions in the transaction group, the caching process packages the at least some transactions into the current block, wherein the already packaged transaction data volume is the data volume of transactions already packaged into the current block at the current moment.
5. The method according to claim 4, wherein when at least some transactions comprise multiple transactions, the caching process packages the at least some transactions into the current block, comprising: The caching process packages each transaction into the current block in the order of their pre-execution.
6. The method according to claim 1, wherein the pre-execution process pre-executes the first transaction based on the block information of the block being packaged, comprising: The pre-execution process calls the block information of the block being packaged through a preset application programming interface, and pre-executes the first transaction based on the block information.
7. The method according to claim 1, wherein the caching process determines the block information dependent on the pre-execution process of the first transaction, comprising: The caching process receives the block information sent by the pre-execution process in association with the first transaction; or, The caching process searches for the block information corresponding to the first transaction based on the correspondence between the transaction and the block information on which the pre-execution process depends, which it maintains.
8. The method according to claim 1, wherein the caching process triggers the pre-execution process to re-pre-execute the first transaction based on the first block information, comprising: The caching process provides the first block information as context information for the first transaction to the pre-execution process, so that the pre-execution process can re-pre-execute the first transaction based on the first block information.
9. The method according to claim 1, wherein the first node further comprises a computing process. The method further includes: The pre-execution process sends the pre-execution read / write set and / or pre-execution result of the first transaction to the caching process; The caching process packages the first transaction into the current block, including: the caching process triggers the computing process to execute the first transaction, and obtains the execution read / write set and / or execution result of the first transaction returned by the computing process; In addition, if the pre-execution read-write set of the first transaction is the same as the execution read-write set, and / or the pre-execution result of the first transaction is the same as the execution result, the first transaction is packaged into the current block.
10. The method according to claim 1, further comprising: The pre-execution process pre-executes the third transaction without relying on any block information and sends the pre-executed third transaction to the cache process; The caching process packages the third transaction into the current block.
11. The method according to claim 1, wherein the block information of any block includes the block height and / or the block timestamp.
12. A block generation method, applied to a first node in a blockchain network, the first node comprising a caching process and a pre-execution process, the method comprising: The pre-execution process relies on the block information of the block being packaged to pre-execute at least a portion of the transactions in the transaction group, and sends the pre-executed at least a portion of the transactions to the caching process; The caching process determines the block information that at least some of the transactions depend on during the pre-execution process, and determines the first block information of the current block that it is currently packaging. When the block information is a second block information that is different from the first block information, the caching process triggers the pre-execution process to re-pre-execute at least some of the transactions based on the first block information; When the block information is the first block information, the caching process packages at least a portion of the transactions into the current block.
13. The method according to claim 12, The pre-execution process relies on block information of the block being packaged to pre-execute at least a portion of the transactions in the transaction group, including: The pre-execution process relies on block information of the block being packaged to pre-execute a portion of the transactions in the transaction group; The method further includes: the pre-execution process pre-executes the remaining transactions in the transaction group except for the aforementioned partial transactions without relying on any block information, and sends the pre-executed remaining transactions to the cache process.
14. The method of claim 13, wherein the caching process packages at least a portion of the transactions into the current block, comprising: The caching process packages each transaction in the transaction group into the current block.
15. A block generation apparatus, applied to a first node in a blockchain network, the first node comprising a caching process and a pre-execution process, the apparatus comprising: The pre-execution unit is used to enable the pre-execution process to pre-execute the first transaction based on the block information of the block being packaged, and to send the pre-executed first transaction to the cache process; The information determination unit is used to enable the caching process to determine the block information that the first transaction depends on during the pre-execution process, and to determine the first block information of the current block that it is currently packaging. The re-pre-execution unit is used to enable the cache process to trigger the pre-execution process to re-pre-execute the first transaction based on the first block information when the block information is a second block information that is different from the first block information; A transaction packaging unit is used to enable the caching process to package the first transaction into the current block when the block information is the first block information.
16. A block generation apparatus, applied to a first node in a blockchain network, the first node comprising a caching process and a pre-execution process, the apparatus comprising: A pre-execution unit is configured to enable the pre-execution process to pre-execute at least a portion of the transactions in the transaction group based on the block information of the block being packaged, and to send the pre-executed at least a portion of the transactions to the cache process; An information determination unit is used to enable the caching process to determine the block information that the at least part of the transactions depend on during the pre-execution process, and to determine the first block information of the current block that it is currently packaging. The re-pre-execution unit is used to enable the caching process to trigger the pre-execution process to re-pre-execute at least a portion of the transactions based on the first block information when the block information is a second block information that is different from the first block information; A transaction packaging unit is used to enable the caching process to package at least a portion of the transactions into the current block when the block information is the first block information.
17. An electronic device comprising: processor; Memory used to store processor-executable instructions; The processor implements the method as described in any one of claims 1-14 by executing the executable instructions.
18. A computer-readable storage medium having stored thereon computer instructions that, when executed by a processor, implement the steps of the method as claimed in any one of claims 1-14.