CN116204335A - Block generation method and device - Google Patents

Block generation method and device Download PDF

Info

Publication number
CN116204335A
CN116204335A CN202211736019.3A CN202211736019A CN116204335A CN 116204335 A CN116204335 A CN 116204335A CN 202211736019 A CN202211736019 A CN 202211736019A CN 116204335 A CN116204335 A CN 116204335A
Authority
CN
China
Prior art keywords
transaction
block
block information
execution
information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211736019.3A
Other languages
Chinese (zh)
Inventor
王毅飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ant Blockchain Technology Shanghai Co Ltd
Original Assignee
Ant Blockchain Technology Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ant Blockchain Technology Shanghai Co Ltd filed Critical Ant Blockchain Technology Shanghai Co Ltd
Priority to CN202211736019.3A priority Critical patent/CN116204335A/en
Publication of CN116204335A publication Critical patent/CN116204335A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The specification provides a block generation method and device. The method is applied to a first node in a blockchain network, wherein the first node comprises a caching process and a pre-executing process, and comprises the following steps: the pre-execution process pre-executes a first transaction according to the block information of the block being packed, and sends the pre-executed first transaction to the caching process; the caching process determines the block information relied on in the pre-execution process of the first transaction, and determines the first block information of the current block which is being packaged at the current moment; the caching process triggers the pre-execution process to re-pre-execute the first transaction depending on the first block information under the condition that the block information is second block information different from the first block information; and the caching process packages the first transaction into the current block under the condition that the block information is the first block information.

Description

Block generation method and device
Technical Field
The embodiment of the specification belongs to the technical field of block chains, and particularly relates to a block generation method and device.
Background
Blockchain (Blockchain) is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanisms, encryption algorithms, and the like. In the block chain system, the data blocks are combined into a chain data structure in a sequential connection mode according to the time sequence, and the distributed account book which is not tamperable and counterfeit and is ensured in a cryptographic mode is formed. Users can participate in realizing related transactions of the blockchain through the blockchain link points, for example, a plurality of blockchain nodes corresponding to different users in a blockchain system respectively can perform Secure Multi-party computing (SMPC) and the like on private data of a certain node based on privacy technologies such as homomorphic encryption, zero knowledge proof and the like.
The blockchain node at the present stage usually pre-executes the transaction to be executed and obtains the result of pre-executing the read-write set and the like before packing the transaction into the block, so that after packing the transaction into the block, the transaction in the block can be executed in groups according to the result. Some transactions require the pre-execution or execution of the transaction to rely on the block information of the block in which the transaction is located.
In the related art, transactions are generally packed into blocks (or chunks) in a consensus process after the pre-execution is completed, and the pre-execution process and the chunk process are two processes independent of each other. Since the pre-execution takes a certain time, some transactions that rely on the tile information of the tile being packed may not be packed into the tile after the pre-execution is completed. In this regard, if the transactions are executed depending on the block information of the block where the transactions are currently located, the actual execution result of the transactions is different from the pre-execution result thereof, which may cause a packet error to cause the blockchain to diverge.
Disclosure of Invention
The invention aims to provide a block generation method, a node and a block chain system.
In a first aspect, a block generating method is provided, applied to a first node in a blockchain network, where the first node includes a caching process and a pre-executing process, and the method includes:
the pre-execution process pre-executes a first transaction according to the block information of the block being packed, and sends the pre-executed first transaction to the caching process;
the caching process determines the block information relied on in the pre-execution process of the first transaction, and determines the first block information of the current block which is being packaged at the current moment;
the caching process packages a first transaction into the current block under the condition that the block information is first block information;
and triggering the pre-execution process to re-pre-execute the first transaction according to the first block information under the condition that the block information is second block information different from the first block information.
In a second aspect, another block generating method is provided, applied to a first node in a blockchain network, where the first node includes a caching process and a pre-executing process, and the method includes:
the pre-execution process pre-executes at least part of transactions in the transaction group according to the block information of the block being packed, and sends the pre-executed at least part of transactions to the cache process;
The caching process determines the block information relied on in the pre-execution process of the at least partial transaction, and determines the first block information of the current block which is being packaged at the current moment;
the caching process packages the at least partial transaction into the current block under the condition that the block information is first block information;
and triggering the pre-execution process to re-pre-execute the at least part of the transactions depending on the first block information under the condition that the block information is second block information different from the first block information.
In a third aspect, a block generating apparatus is provided, applied to a first node in a blockchain network, where the first node includes a caching process and a pre-executing process, and the apparatus includes:
the pre-execution unit is used for enabling the pre-execution process to pre-execute a first transaction according to the block information of the block being packed, and sending the pre-executed first transaction to the cache process;
the information determining unit is used for enabling the caching process to determine the block information which is dependent in the pre-execution process of the first transaction and determine the first block information of the current block which is being packaged at the current moment;
The transaction packaging unit is used for enabling the caching process to package the first transaction into the current block under the condition that the block information is the first block information;
and the re-pre-executing unit is used for triggering the pre-executing process to re-pre-execute the first transaction depending on the first block information under the condition that the block information is second block information different from the first block information.
In a fourth aspect, another block generating apparatus is provided, applied to a first node in a blockchain network, where the first node includes a caching process and a pre-executing process, and the apparatus includes:
the pre-execution unit is used for enabling the pre-execution process to pre-execute at least part of transactions in the transaction group according to the block information of the block being packed, and sending the pre-executed at least part of transactions to the cache process;
the information determining unit is used for enabling the caching process to determine the block information which is dependent in the pre-execution process of the at least partial transaction and determine the first block information of the current block which is being packaged at the current moment;
a transaction packaging unit, configured to enable the caching process to package the at least part of the transaction into the current block when the block information is the first block information;
And the re-pre-executing unit is used for enabling the caching process to trigger the pre-executing process to re-pre-execute the at least part of transactions depending on the first block information under the condition that the block information is second block information different from the first block information.
According to a fourth aspect of one or more embodiments of the present specification, there is provided an electronic device comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor implements the method of any of the first or second aspects by executing the executable instructions.
According to a fifth aspect of one or more embodiments of the present description, there is provided a computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method as in any of the first or second aspects.
Through the above embodiment, the pre-execution process in the first node may pre-execute the first transaction depending on the block information of the block being packed, and send the pre-executed first transaction to the cache process. The caching process receiving the first transaction can acquire the block information relied on in the execution process of the transaction, and determine the first block information of the current block which is being packaged at the current moment; then judging whether the block information and the first block information are identical or not as identical information: if the first transaction and the second transaction are the same information, packing the first transaction into the current block; otherwise, triggering the pre-execution process to re-pre-execute the first transaction depending on the first block information.
Therefore, the method and the system have the advantages that the blocking process of the transaction is arranged in front, namely, the blocking process is combined with the pre-execution process, so that the blocking condition of any transaction can feedback to influence the pre-execution process of the transaction. Since the pre-execution process of the first transaction depends on the block information, and the current block is being packed by the buffer process at the current time, if the block information is the second block information different from the first block information, that is, 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 forcefully packed into the current block, the execution result obtained by actually executing the transaction in the block by the node depending on the block information of the block after consensus (i.e., the first block information) is different from the pre-execution result thereof, thereby possibly causing the block chain bifurcation. Otherwise, if the block information is the first block information of the current block, that is, the pre-execution process of the first transaction is finished depending on the first block information of the current block, the first transaction is packed to the current block at this time, so that it can be ensured that the node can actually execute the first transaction depending on the first block information after the block passes through the consensus, thereby obtaining the execution result identical to the pre-execution result, and effectively avoiding the bifurcation of the block chain.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings that are needed in the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present disclosure, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of any two nodes in a blockchain system according to an exemplary embodiment.
Fig. 2 is a flowchart of a block generation method according to an exemplary embodiment.
Fig. 3 is a flowchart of another block generation method according to an exemplary embodiment.
Fig. 4 is a schematic diagram of an apparatus according to an exemplary embodiment.
Fig. 5 is a block diagram of a block generating apparatus according to an exemplary embodiment.
Fig. 6 is a block diagram of another block generating apparatus provided by an exemplary embodiment.
Detailed Description
In order to make the technical solutions in the present specification better understood by those skilled in the art, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
The blockchain system establishes a distributed network through a plurality of nodes, wherein any two nodes are connected through Peer-to-Peer (P2P) network in communication at an application layer. The blockchain system uses the decentralized (or called multicentric) distributed ledger constructed by the chain type blockchain structure to be stored on each node (or on a large number of nodes, such as a common node) in the distributed blockchain system, so that the blockchain system needs to solve the problem of consistency and correctness of the data of the respective ledger on a plurality of nodes which are decentralized (or multicentric). In view of this, each node of the blockchain system is running a blockchain program, and under the design of a certain fault tolerance requirement, all the loyalty nodes are guaranteed to have the same transaction through a consensus (consensus) mechanism, so that the consistency of the execution results of all the loyalty nodes on the same transaction is guaranteed, the transactions are packed into blocks, and the world state is updated based on the execution results of the same transaction. Among the currently prevailing consensus mechanisms include, but are not limited to: proof of Work (POW), proof of stock (POS), practical bezels fault tolerance (Practical Byzantine Fault Tolerance, PBFT) algorithms, meles bezels fault tolerance (honeybadger bft) algorithms, and the like.
As described above, in the related art, if the pre-execution process of a transaction depends on the block information of the block B1, and the transaction is subsequently packed into the block B2 (i.e. not packed into the block B1), after the block B2 passes the consensus, the actual execution result of the transaction will be different from the pre-execution result of the transaction when the block chain node in the block chain network executes the transaction, which may cause the block chain to diverge.
In order to solve the above-mentioned problems in the related art, the present disclosure proposes a block generation method, in which, by pre-setting the packing process of the transaction to the pre-execution process, re-pre-execution of the transaction is implemented by comparing block information, so that the transaction pre-executed by the block information of any block can be accurately packed into the block, thereby ensuring that the actual execution result of the transaction is the same as the pre-execution result thereof, and effectively avoiding the block chain from generating bifurcation. The block generation method is described in detail below with reference to the accompanying drawings.
The block generation method described in the present specification is applied to a first node in a blockchain network, where the first node may be any node in the blockchain network, and the node may be implemented as an apparatus, a platform, a device, or a cluster of devices with computing/processing capabilities. The various processes involved in the first node are first described in connection with fig. 1. Fig. 1 is a schematic diagram of any two nodes in a blockchain system according to an exemplary embodiment.
As shown in fig. 1, any two nodes n1 and n2 in the blockchain network each contain multiple processes to provide multiple services. For example, the node n1 and the node n2 each include an access process for providing an access service to the blockchain network (e.g., the access process 1 included in the node n1 and the access process 2 included in the node n2, and the other process numbers have the same meaning as the similar, and are not described in detail), a caching process for providing a caching service, a pre-execution process for providing a pre-execution service, a network process for providing a network service, a consensus process for providing a consensus service, a control process for providing a block management service, a storage process for providing a storage service, and the like. It is assumed that node n1 and node n2 are a slave node and a master node, respectively, in the blockchain network. At this time, the node n1 may further include a plurality of computing processes for providing computing services, such as the computing process 11, the computing process 12, and the computing process 13. At present, the node n2 may also include at least one computing process for executing the transaction included in the block through consensus, which is not described in detail.
In this specification, a process refers to a running activity of a program with a certain independent function in an application with respect to a data set, that is, the process is a process in a computer by sequentially executing instructions in the application program by a CPU, and each process is allocated its own memory address space when created. The plurality of processes in any node may be a plurality of computing devices or a plurality of processes in a virtual computing node. In addition, it should be noted that the scheme provided in the embodiments of the present disclosure is not limited to the blockchain system of the master-slave architecture; in other words, the node n1 and the node n2 in this embodiment may be any two blockchain nodes in the blockchain system.
Fig. 2 is a flowchart of a block generation method according to an exemplary embodiment. As shown in fig. 2, the method is applied to a first node in a blockchain network, the first node including a caching process and a pre-execution process. As previously described, the first node may be any node in the blockchain network, such as node n1 or node n2 shown in fig. 1. The method includes the following steps 202-206b.
Step 202, the pre-executing process pre-executes the first transaction according to the block information of the block being packaged, and sends the pre-executed first transaction to the caching process.
The caching process in the first node may be configured to maintain pending (e.g., to be packaged) transactions received by the node, i.e., to cache transactions locally at the first node. For example, the caching process may record each transaction received by the first node in a pending transaction queue maintained by itself. For example, the caching process may record each transaction in the transaction queue in sequence according to the sequence of the initiating time of each transaction (i.e. the time when the transaction initiator initiates the transaction) or according to the sequence of the receiving time of each transaction by the first node (i.e. the time when the first node receives the transaction), so as to process each transaction in sequence according to the sequence. The first transaction in this embodiment may be any transaction maintained by the caching process.
Each transaction in the message queue needs to be pre-executed before being packed, so that the caching process needs to send each transaction to the pre-executing process. Wherein, some or all transactions in the transaction queue may need to rely on the tile information of the tile in the pre-execution process, i.e. the pre-execution process may need to pre-execute certain transactions in dependence on the tile information. In this regard, the caching process may send each transaction to be packaged to the pre-execution process in a multi-charge manner.
In one embodiment, the caching process may send only transactions to the pre-execution process. If the transaction queue is used, each transaction in the transaction queue can be sent to the pre-execution process one by one, or a plurality of continuous transactions in the transaction queue can be sent to the pre-execution process as a group (hereinafter referred to as a transaction group) at one time, so that the interaction times with the pre-execution process are reduced, and the transaction transfer efficiency between the two processes is improved. At this time, the pre-execution process receives the transaction only from the cache process, so the pre-execution process may also call the tile information of the tile being packed (such as the nth tile) through the preset API (Application Programming Interface ), and pre-execute the first transaction depending on the tile information. For example, a hook may be added to the hostAPI method so that the pre-execution process may call tile information of a tile that the cache process is packaging through the hostAPI.
In another embodiment, the caching process may send the transaction and its block information associations that need to be relied upon to the pre-execution process. For example, before the first transaction is to be sent, the buffer process may determine whether the transaction needs to rely on the block information in the pre-executing process, and in the case that it is determined that the first transaction needs to rely on the block information, send the first transaction and the block information of the block (such as the nth block) that is being packaged by the buffer process at the current time to the pre-executing process in an associated manner. Or, in order to improve the transmission efficiency of the transaction and the transmission times of the block information, before sending the transaction group, the buffer process may determine whether the transaction group includes a transaction that needs to rely on the block information in the pre-execution process, and if there is such a transaction in the transaction group (such as that such a transaction includes at least a first transaction), send the transaction group and the block information of the block (such as the nth block) that is being packaged by the buffer process at the current time to the pre-execution process in an associated manner.
As an exemplary embodiment, the pre-executing process may receive the transaction group sent by the caching process and the block information of the block (such as the nth block) being packed by the caching process, and then pre-execute at least part of the transactions including the first transaction in the transaction group according to the received block information, and send the pre-executed at least part of the transactions to the caching process. The at least partial transaction may include only the first transaction (only the pre-execution process of the first transaction in the transaction group needs to rely on the block information), and 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 cache process. Alternatively, the at least partial transaction may include, in addition to the first transaction, a second transaction, similar to the first transaction, whose pre-execution process also requires reliance on tile information. And the number of the second transactions may be one or more, that is, the second transactions are the same type of transactions that need to rely on block information in the pre-execution process, and obviously, the first transactions and the second transactions are both the type of transactions. Therefore, when the transaction group further includes a second transaction, the pre-execution process may pre-execute the first transaction and the second transaction according to the block information, and send the pre-executed first transaction and second transaction to the cache process.
Still alternatively, the transaction group may include a third transaction in which the pre-execution process does not need to rely on any block information, in addition to the first transaction (or the first transaction and the second transaction) in which the pre-execution process also needs to rely on block information. Similarly, the number of third transactions may be one or more, i.e. the third transactions are the same type of transactions for which no blocking information needs to be relied upon by the pre-execution process. In this regard, the pre-execution process may also execute the third transaction without relying on any block information, and send the executed third transaction to the cache process. Alternatively, the caching process may send the third transaction to the pre-execution process, i.e. not including the third transaction in the transaction group, whether the caching process sends the first transaction to the pre-execution process alone or the first transaction is included in the transaction group (along with other transactions) to the pre-execution process. In this regard, the pre-execution process may also pre-execute the third transactions without relying on any block information, and send the executed third-party transactions to the caching process.
In the above manner, the pre-execution process may pre-execute each transaction received by itself. For the first transaction and the second transaction, since the pre-execution process depends on the block information, the caching process needs to further determine whether the block information actually relied on by the pre-execution process is consistent with the block information of the current block being packaged at the current time of the caching process. For the third transaction, whether the third transaction is included in the transaction group or not, the caching process may directly package the third transaction into the current block, which is not described again.
For the first transaction, the present description embodiment relates to two pieces of block information: the block information relied by the pre-execution stage and the block information of the current block being processed by the caching process after receiving the first transaction after the pre-execution stage are possibly the same or different. It should be noted that, the block information of any block described in the embodiments of the present disclosure may include a block height (block height) and/or a block timestamp (timestamp) of the block.
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 may pre-execute the first transaction depending on the block information and send the pre-executed first transaction to the caching process. The pre-execution process corresponds to corresponding pre-execution information, and the information may include the block information, and may further include a pre-execution result of the first transaction and a pre-execution read-write set generated by pre-execution. Wherein the pre-execution read-write sets may include pre-execution read sets (corresponding to data read operations involved in the execution of the transaction) and/or pre-execution write sets (corresponding to data write operations involved in the execution of the transaction). In this regard, the pre-execution process may also send the pre-execution information to the caching process in association with the first transaction. Or, in the case that the block information is sent to the pre-execution process by the cache process, the cache process may maintain the corresponding relationship between the first transaction and the block information by itself, where the pre-execution process may only return the pre-execution result and/or the pre-execution read-write set to the cache process, without returning the block information.
In addition, it should be noted that, in the present embodiment, the caching process and the pre-execution process in the first node cooperate together to implement the pre-execution and packaging process for the first transaction. For a plurality of transactions to be processed received by the first node, the caching process, the pre-execution process and the consensus process in the first node may cooperate with each other, and the pre-execution, packaging, consensus, transaction execution and block writing processes for each transaction are implemented in parallel in a pipelined manner (or referred to as a block pipeline). For example, at any time, the block pipeline may commonly recognize the number 100 block, execute the transaction in the number 99 block, write the number 98 block, etc., which will not be described again.
In step 204, the caching process determines the block information that is dependent in the pre-execution process of the first transaction, and determines the first block information of the current block that is being packaged at the current time.
After receiving the executed first transaction sent by the pre-execution process, the caching process may determine, on one hand, the block information (i.e., the block information of the block being packaged determined by the caching process in step 202) that is relied on in the pre-execution process of the transaction, and on the other hand, may determine the first block information of the current block being packaged at the current moment.
In an embodiment, the caching process may determine whether the first transaction is a Replay transaction (i.e. detect whether a Replay attack exists) according to a preset rule. If the first transaction is a replay transaction, packaging the first transaction should be terminated and relevant information of the first transaction recorded, and/or an alarm for replay provision should be initiated, etc. Otherwise, if the first transaction is not a replay transaction, the subsequent processing procedure for the first transaction is restarted. Of course, the above replay attack detection procedure may also be performed by the caching process upon receipt of the first transaction. For each transaction received by the first node, the caching process may determine whether to replay the transaction according to the foregoing preset rule: if any transaction is a replay transaction, the subsequent processing process for the transaction can be terminated, so that the invalid pre-execution for the replay transaction is effectively avoided, and the efficiency of the effective pre-execution of the pre-execution process is improved; otherwise, if any transaction is not a replay transaction, then the subsequent processing for the transaction is resumed (e.g., recording the transaction in the transaction queue, sending the transaction to a pre-execution process for pre-execution, etc.).
In one embodiment, the caching process may determine the tile information relied upon during the pre-execution of the first transaction in a number of ways. For example, after the pre-execution process finishes pre-executing the first transaction depending on the block information, the block information may be sent to the caching process in association with the first transaction, so that the caching process may determine the block information if the block information is received. For another example, in the case that the block information on which one or more transactions and the pre-execution process thereof need to depend in the transaction queue is sent to the pre-execution process, the caching process may maintain a correspondence relationship between the block information on which the transactions and the pre-execution process thereof depend. Based on the above, after receiving the first transaction, the caching process may search the block information corresponding to the first transaction according to the correspondence.
It will be appreciated that, since the process of pre-executing the first transaction by the pre-execution process needs to consume a certain amount of time, at the current time after the first transaction is received, the current block being packed by the buffering process may be the block corresponding to the block information (i.e. the buffering process has not completed the packing process of the block during the pre-execution process of the first transaction), or may not be the block corresponding to the block information (i.e. the buffering process has completed the packing process of the block corresponding to the block information during the pre-execution process of the first transaction, and the current block being packed now is another block after the block corresponding to the block information). Based on this, the caching process may determine whether the block information is first block information: if the block information is second block information (i.e., the block information is not the first block information) different from the first block information, go to step 206a; otherwise, if the block information is the first block information, the step proceeds to step 206b.
In step 206a, the caching process triggers the pre-execution process to re-pre-execute the first transaction depending on the first block information if the block information is the second block information different from the first block information.
The block information is second block information different from the first block information, that is, the block information on which the first transaction pre-execution process depends is not the first block information, which indicates that the block corresponding to the block information has been packaged (may be that the execution of all transactions in the first transaction or the transaction group takes too long), in the blockchain ledger, after the current block is added to the block corresponding to the block information (the interval between the current block and the block is determined by the block heights of the current block and the current block). At this time, the caching process may trigger the pre-execution process to re-pre-execute the first transaction in dependence on the first tile information of the current tile, so as to subsequently attempt to package the first transaction into the current tile.
In an embodiment, the caching process may provide the first tile information as Context information of the first transaction to the pre-execution process to re-pre-execute the first transaction by the pre-execution process in dependence on the first tile information. Of course, the caching process may reset the context information for the first transaction according to the current block, which is not described in detail.
Wherein the caching process may trigger only the pre-execution process to re-pre-execute the first transaction in dependence of the first block information. Or, in the case that the transaction group to which the first transaction belongs further includes the second transaction, the caching process may trigger the pre-execution process to re-pre-execute the first transaction and each second transaction depending on the first block information. By the method, each transaction which needs to be pre-executed depending on the block information can be ensured to be re-pre-executed by the pre-execution process depending on the first block information, so that the data preparation is carried out for packaging the transactions to the current block again by the caching process.
Still alternatively, in the case that the transaction group to which the first transaction belongs further includes a third transaction, the caching process may 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 second transaction) depending on the first block information, and re-pre-executes each third transaction independent of any block information.
In step 206b, the caching process packages the first transaction into the current block if the block information is the first block information.
The block information is first block information, namely the first transaction pre-execution process depends on the first block information, and the block which is sent by the caching process and is being packaged by the first transaction is the current block information. At this point, the caching process may package the first transaction into the current block.
Therefore, the method and the system have the advantages that the blocking process of the transaction is arranged in front, namely, the blocking process is combined with the pre-execution process, so that the blocking condition of any transaction can feedback to influence the pre-execution process of the transaction. Since the pre-execution process of the first transaction depends on the block information, and the current block is being packed by the buffer process at the current time, if the block information is the second block information different from the first block information, that is, 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 forcefully packed into the current block, the execution result obtained by actually executing the transaction in the block by the node depending on the block information of the block after consensus (i.e., the first block information) is different from the pre-execution result thereof, thereby possibly causing the block chain bifurcation. Otherwise, if the block information is the first block information of the current block, that is, the pre-execution process of the first transaction is finished depending on the first block information of the current block, the first transaction is packed to the current block at this time, so that it can be ensured that the node can actually execute the first transaction depending on the first block information after the block passes through the consensus, thereby obtaining the execution result identical to the pre-execution result, and effectively avoiding the bifurcation of the block chain.
In one embodiment, to ensure that the size of the blocks generated by packing is uniform, the current block may be generally set to a maximum number of transactions (i.e., the number of transactions that can be packed into the block at most) and/or a maximum amount of transaction data (i.e., the amount of data that can be packed into the block at most). In this regard, the caching process may ensure that the number of current blocks packed does not exceed the maximum transaction number and/or that the data amount of the current blocks does not exceed the maximum transaction data amount when packing the first transaction to the current blocks. For example, the caching process may determine the number of packaged transactions, i.e., the number of transactions that have been packaged into the current block at the current time, prior to packaging the first transaction. The caching process may then package a first transaction to the current block if a difference between a maximum number of transactions for the current block and a packaged number of transactions is not less than 1. Alternatively, as received in the foregoing embodiment, if the first transaction is included in the transaction group and the pre-execution process pre-executes at least part of the transactions including the first transaction in the transaction group according to the block information, the caching process may package the at least part of the transactions to the current block if a difference between a maximum transaction number of the current block and a packaged transaction number is not smaller than the transaction number of the at least part of the transactions. In this way, at least part of the transactions including the first transaction may be packed into the current block in the same way, thereby ensuring that the part of the transactions pre-performed in dependence of the same block information (i.e. the block information) is packed into the same block (i.e. the current block) while ensuring that the number of transactions packed in the current block does not exceed its maximum number of transactions.
For another example, the caching process may also determine the amount of data of the packaged transaction, i.e. the amount of data of the transaction that has been packaged into the current block at the current time, before packaging the first transaction. The caching process may then package the first transaction to the current block if a difference between the maximum transaction data amount and the packaged transaction data amount of the current block is not less than the data amount of the first transaction. Alternatively, as received in the foregoing embodiment, if the first transaction is included in the transaction group and the pre-execution process pre-executes at least a portion of the transactions including the first transaction in the transaction group depending on the block information, the caching process may package the at least a portion of the transactions to the current block if a difference between a maximum transaction data amount of the current block and a packaged transaction data amount is not smaller than the transaction data amount of the at least a portion of the transactions. In this way, at least part of the transactions including the first transaction may be packed into the current block in the same way, thereby ensuring that the part of the transactions pre-executed in dependence of the same block information (i.e. the block information) is packed into the same block (i.e. the current block) while ensuring that the amount of transaction data packed in the current block does not exceed its maximum amount of transaction data.
In addition, in the case where the aforementioned at least partial transaction includes a plurality of transactions, the caching process may sequentially pack the respective transactions to the current block in a pre-execution order of the plurality of transactions. As described above, the plurality of transactions include each transaction pre-executed in the transaction group depending on the same block information (i.e., the block information), and in this way, the transactions may be packaged into the same block (i.e., the current block), so that each node in the blockchain network may execute each transaction according to the pre-execution sequence based on the first block information of the current block information after the block passes through consensus, further ensuring that the actual execution result of each transaction is the same as the pre-execution result thereof, so as to implement accurate execution of each transaction, and effectively avoid bifurcation of the blockchain.
As mentioned before, the first node may further include a computing process, and the pre-executing process pre-executes the first transaction to obtain a corresponding pre-execution read-write set and/or a pre-execution result. Based on the above, the pre-execution process may send the pre-execution read-write set and/or pre-execution result to the cache process; correspondingly, the caching process can trigger the computing process to execute the first transaction, and acquire an execution read-write set and/or an execution result of the first transaction returned by the computing process. Based on this, the caching process may package the first transaction into the current block 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.
In another embodiment, the caching process may further compare the pre-performed read-write set of the first transaction with the pre-performed read-write set of the forward transactions already packed to the current block at the current time (i.e., the transactions in the current block before the first transaction) to determine whether the pre-performed read-write set of the first transaction conflicts with the pre-performed read-write set of some forward transactions. If such online transactions exist, packaging the first transaction to the current tile should be avoided (because if the first transaction is forced to be packaged to the current tile, each transaction in the tile will have read-write set conflicts when actually executed, causing transaction execution and in-chain data write errors); conversely, in the absence of such forward transactions (i.e., no conflict between the pre-execution read-write set of the first transaction and the pre-execution read-write set of each forward transaction), the first transaction may be packed into the current block.
Thus, the process of packing the first transaction into the current block is described. As previously described, the caching process may send the first transaction contained in the transaction group to the pre-execution process, which may then pre-execute (and re-pre-execute) the respective transactions contained therein in transaction groups. In this regard, the present specification also proposes another block generation method.
Fig. 3 is a flowchart of another block generation method according to an exemplary embodiment. As shown in FIG. 3, the method is applied to a first node in a blockchain network, the first node including a caching process and a pre-execution process, each including steps 302-306b described below.
Step 302, the pre-executing process pre-executes at least part of the transactions in the transaction group according to the block information of the block being packed, and sends the pre-executed at least part of the transactions to the caching process.
In step 304, the caching process determines the block information that is dependent in the pre-execution process of the at least partial transaction, and determines the first block information of the current block that is being packaged at the current time.
In step 306a, the caching process triggers the pre-execution process to re-pre-execute the at least part of the transaction depending on the first block information if the block information is the second block information different from the first block information.
In step 306b, the buffering process packages the at least partial transaction into the current block if the block information is the first block information.
In one embodiment, the transaction group may include transactions (first transaction, or first and second transactions, as described above) that require a blockchain network for at least one pre-execution process. At this time, the pre-execution process may pre-execute all transactions in the transaction group depending on the tile information of the tile that the caching process is packaging.
In another embodiment, in addition to transactions that require block information for the pre-execution process, transactions that do not require any block information for the pre-execution process (such as the third transaction described above) may be included in the transaction group. At this time, the pre-execution process may pre-execute a part of the transactions in the transaction group depending on the tile information of the tile being packaged by the cache process (i.e., the pre-execution process needs a part of the transactions depending on the tile information, such as the first transaction or the first transaction and the second transaction), and may pre-execute the rest of the transactions in the transaction group excluding the part of the transactions without depending on any tile information (i.e., the pre-execution process does not need any transaction of the tile information, such as the third transaction), and send the rest of the pre-executed transactions to the cache process. Through the above process, the pre-execution process can complete the pre-execution process of each transaction in the transaction group based on the corresponding data.
Further, when packaging the at least partial transaction into the current block, the caching process may package each transaction in the transaction group into the current block together. Specifically, in the case that the transaction group only includes a portion of transactions that need to rely on block information in the pre-execution process, the caching process may package all of the portion of transactions into the current block; in the case where the transaction group includes both a partial transaction in which the pre-execution process needs to rely on tile information and other transactions in which the pre-execution process does not need to rely on tile information, the caching process may package all transactions (i.e., the partial transaction and other transactions described above) into the current tile. By the method, all transactions which are pre-executed and completed in the same transaction group and depend on the same block information can be ensured to be accurately packaged into the same block, and the method is beneficial to further ensuring that the actual execution result obtained by actually executing the transactions is the same as the pre-execution result, and avoiding the bifurcation of a block chain.
In addition, for the specific process of pre-executing and packaging the partial transactions in the transaction group, reference may also be made to the description of the corresponding embodiment in fig. 1, which is not repeated herein.
Similar to the previous solution, the present solution pre-sets the blocking process of the transaction, i.e. merges the blocking process with the pre-execution process, so that the blocking situation of a part of the transactions (the pre-execution process needs to depend on the block information) in the transaction group can feedback the pre-execution process affecting the part of the transactions. Since the pre-execution process of the partial transaction depends on the block information, and the current block is being packed by the buffer process at the current time, if the block information is the second block information different from the first block information, that is, the pre-execution process of the partial transaction does not depend on the first block information of the current block, if the partial transaction is forcedly packed to the current block, the execution result obtained by actually executing the partial transaction in the block by the node depending on the block information of the block after consensus (i.e., the first block information) is different from the corresponding pre-execution result, thereby possibly causing the blockchain bifurcation. Otherwise, if the block information is the first block information of the current block, that is, it indicates that the pre-execution process of the partial transaction is completed depending on the first block information of the current block, and the partial transaction is packaged to the current block at this time, it can be ensured that after the block passes through the consensus, the node can actually execute the partial transaction depending on the first block information, thereby obtaining an actual execution result identical to the pre-execution result, and effectively avoiding the bifurcation of the blockchain.
Fig. 4 is a schematic block diagram of an apparatus according to an exemplary embodiment. Referring to fig. 4, at the hardware level, the device includes a processor 402, an internal bus 404, a network interface 406, a memory 408, and a nonvolatile memory 410, although other hardware required by other services is possible. One or more embodiments of the present description may be implemented in a software-based manner, such as by the processor 402 reading a corresponding computer program from the non-volatile memory 410 into the memory 408 and then running. Of course, in addition to software implementation, one or more embodiments of the present disclosure do not exclude other implementation manners, such as a logic device or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but may also be hardware or a logic device.
Fig. 5 is a block diagram of a block generating apparatus according to an exemplary embodiment of the present disclosure, which may be applied to the device shown in fig. 4 to implement the technical solution of the present disclosure. The apparatus is applied to a first node in a blockchain network, the first node including a caching process and a pre-execution process, the apparatus comprising:
A pre-execution unit 501, configured to cause the pre-execution process to pre-execute a first transaction depending on block information of a block being packed, and send the pre-executed first transaction to the cache process;
an information determining unit 502, configured to enable the caching process to determine the block information that is dependent in the pre-execution process of the first transaction, and determine first block information of a current block that is being packaged at the current moment;
a re-pre-execution unit 503, configured to cause the caching process to trigger the pre-execution process to re-pre-execute the first transaction depending on the first block information if the block information is second block information different from the first block information;
and a transaction packaging unit 504, configured to enable the caching process to package the first transaction into the current block if the block information is the first block information.
Optionally, the pre-execution unit 501 is further configured to:
the pre-executing process receives a transaction group sent by the caching process and block information of a block being packaged by the caching process, wherein the transaction group at least comprises a first transaction;
and enabling the pre-execution process to pre-execute at least part of the transactions including the first transaction in the transaction group according to the received block information, and sending the pre-executed at least part of the transactions to the caching process.
Optionally, the pre-execution unit 501 is further configured to:
and under the condition that the pre-execution process also comprises a second transaction in the transaction group, respectively pre-executing the first transaction and the second transaction according to the block information, and sending the pre-executed first transaction and second transaction to the caching process.
Optionally, the transaction packaging unit 504 is further configured to:
causing the caching process to pack the at least partial transactions to the current block if a difference between a maximum transaction number and a packed transaction number of the current block is not less than a transaction number of the at least partial transactions in the transaction group, wherein the packed transaction number is a number of transactions packed into the current block at a current time; and/or;
and enabling the caching process to pack the at least partial transaction to the current block under the condition that the difference between the maximum transaction data amount of the current block and the packed transaction data amount is not smaller than the data amount of the at least partial transaction in the transaction group, wherein the packed transaction data amount is the data amount of the transaction packed into the current block at the current moment.
Optionally, in the case that the at least partial transaction includes a plurality of transactions, the transaction packaging unit 504 is further configured to:
and enabling the caching process to sequentially pack all the transactions to the current block according to the pre-execution sequence of the transactions.
Optionally, the transaction packaging unit 504 is further configured to:
and calling the block information of the block being packed by the pre-execution process through a preset application programming interface, and pre-executing the first transaction according to the block information.
Optionally, the information determining unit 502 is further configured to:
enabling the caching process to receive the block information sent by the pre-execution process in association with a first transaction; or,
and the caching process searches the block information corresponding to the first transaction according to the corresponding relation between the transaction maintained by the caching process and the block information relied on in the pre-execution process.
Optionally, the re-pre-execution unit 503 is further configured to:
the caching process is caused to provide the first block information as context information for the first transaction to the pre-execution process for re-pre-execution of the first transaction by the pre-execution process in dependence on the first block information.
Optionally, the first node further comprises a computing process,
The apparatus further includes a result sending unit 505, configured to cause the pre-execution process to send a pre-execution read-write set and/or a pre-execution result of the first transaction to the cache process;
the transaction packaging unit 504 is further configured to: triggering the computing process to execute a first transaction by the caching process, and acquiring an execution read-write set and/or an execution result of the first transaction returned by the computing process; and, the pre-execution read-write set at the first transaction is the same as the execution read-write set; and/or packing the first transaction into the current block under the condition that the pre-execution result of the first transaction is the same as the execution result.
Optionally, the method further comprises:
a transaction execution unit 506, configured to cause the pre-execution process to pre-execute a third transaction independent of any block information, and send the pre-executed third transaction to the cache process;
and a third transaction packaging unit 507, configured to enable the caching process to package a third transaction to the current block.
Optionally, the block information of any block includes a block height and/or a block timestamp.
Fig. 6 is a block diagram of another block generating apparatus according to an exemplary embodiment of the present disclosure, which may be applied to the device shown in fig. 4 to implement the technical solution of the present disclosure. The apparatus is applied to a first node in a blockchain network, the first node including a caching process and a pre-execution process, the apparatus comprising:
A pre-execution unit 601, configured to cause the pre-execution process to pre-execute at least a part of transactions in a transaction group depending on block information of a block being packed, and send the pre-executed at least part of transactions to the cache process;
an information determining unit 602, configured to enable the caching process to determine the block information that is dependent in the pre-execution process of the at least partial transaction, and determine first block information of a current block that is being packaged at the current time;
a re-pre-execution unit 603, configured to cause the caching process to trigger the pre-execution process to re-pre-execute the at least part of the transaction depending on the first block information if the block information is second block information different from the first block information;
and a transaction packaging unit 604, configured to enable the caching process to package the at least part of the transaction into the current block if the block information is the first block information.
Alternatively to this, the method may comprise,
the pre-execution unit 601 is further configured to: pre-executing part of transactions in the transaction group by the pre-executing process according to the block information of the blocks being packed;
the apparatus further comprises a remaining transaction pre-execution unit 605, configured to cause the pre-execution process to pre-execute the remaining transactions except for the partial transaction in the transaction group independent of any block information, and send the pre-executed remaining transactions to the cache process.
Optionally, the transaction packaging unit 604 is further configured to:
and enabling the caching process to package all the transactions in the transaction group into the current block.
In the 90 s of the 20 th century, improvements to one technology could clearly be distinguished as improvements in hardware (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software (improvements to the process flow). However, with the development of technology, many improvements of the current method flows can be regarded as direct improvements of hardware circuit structures. Designers almost always obtain corresponding hardware circuit structures by programming improved method flows into hardware circuits. Therefore, an improvement of a method flow cannot be said to be realized by a hardware entity module. For example, a programmable logic device (Programmable Logic Device, PLD) (e.g., field programmable gate array (Field Programmable Gate Array, FPGA)) is an integrated circuit whose logic function is determined by the programming of the device by a user. A designer programs to "integrate" a digital system onto a PLD without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Moreover, nowadays, instead of manually manufacturing integrated circuit chips, such programming is mostly implemented by using "logic compiler" software, which is similar to the software compiler used in program development and writing, and the original code before the compiling is also written in a specific programming language, which is called hardware description language (Hardware Description Language, HDL), but not just one of the hdds, but a plurality of kinds, 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, RHDL (Ruby Hardware Description Language), etc., VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog are currently most commonly used. It will also be apparent to those skilled in the art that a hardware circuit implementing the logic method flow can be readily obtained by merely slightly programming the method flow into an integrated circuit using several of the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, 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 (Application Specific Integrated Circuit, ASIC), programmable logic controllers, and embedded microcontrollers, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, atmel AT91SAM, microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic of the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller in a pure computer readable program code, it is well possible to implement the same functionality by logically programming the method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. Such a controller may thus be regarded as a kind of hardware component, and means for performing various functions included therein may also be regarded as structures within the hardware component. Or even means for achieving the various functions may be regarded as either software modules implementing the methods or structures within hardware components.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation device is a server system. Of course, the invention does not exclude that as future computer technology advances, the computer implementing the functions of the above-described embodiments may be, for example, a personal computer, a laptop computer, a car-mounted human-computer interaction device, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Although one or more embodiments of the present description provide method operational steps as 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 recited in the embodiments is merely one way of performing the order of steps and does not represent a unique order of execution. When implemented in an actual device or end product, the instructions may be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment, or even in a distributed data processing environment) as illustrated by the embodiments or by the figures. The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, it is not excluded that additional identical or equivalent elements may be present in a process, method, article, or apparatus that comprises a described element. For example, if first, second, etc. words are used to indicate a name, but not any particular order.
For convenience of description, the above devices are described as being functionally divided into various modules, respectively. Of course, when one or more of the present description is implemented, the functions of each module may be implemented in the same piece or pieces of software and/or hardware, or a module that implements the same function may be implemented by a plurality of sub-modules or a combination of sub-units, or the like. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The present 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 flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may 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, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, read only compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
One skilled in the relevant art will recognize that one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, one or more embodiments of the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
One or more embodiments of the present specification may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments. In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present specification. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
The foregoing is merely an example of one or more embodiments of the present specification and is not intended to limit the one or more embodiments of the present specification. Various modifications and alterations to one or more embodiments of this description will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, or the like, which is within the spirit and principles of the present specification, should be included in the scope of the claims.

Claims (18)

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 pre-executes a first transaction according to the block information of the block being packed, and sends the pre-executed first transaction to the caching process;
the caching process determines the block information relied on in the pre-execution process of the first transaction, and determines the first block information of the current block which is being packaged at the current moment;
the caching process triggers the pre-execution process to re-pre-execute the first transaction depending on the first block information under the condition that the block information is second block information different from the first block information;
And the caching process packages the first transaction into the current block under the condition that the block information is the first block information.
2. The method of claim 1, wherein the pre-execution process pre-executes the first transaction in dependence on the tile information of the tile being packed, and sends the pre-executed first transaction to the caching process, comprising:
the pre-execution process receives a transaction group sent by the caching process and block information of a block being packaged by the caching process, wherein the transaction group at least comprises a first transaction;
the pre-execution process pre-executes at least part of the transactions including the first transaction in the transaction group according to the received block information, and sends the at least part of the transactions which are pre-executed to the caching process.
3. The method of claim 2, the pre-execution process pre-executing at least a portion of the transactions in the transaction group including a first transaction in dependence upon the received tile information, comprising:
and under the condition that the transaction group also comprises a second transaction, the pre-execution process pre-executes the first transaction and the second transaction respectively according to the block information, and sends the pre-executed first transaction and second transaction to the caching process.
4. The method of claim 2, the caching process packing a first transaction into the current block, comprising:
the caching process packages the at least partial transaction into the current block under the condition that the difference between the maximum transaction number of the current block and the packaged transaction number is not smaller than the transaction number of the at least partial transaction in the transaction group, wherein the packaged transaction number is the number of the transactions packaged into the current block at the current moment; and/or;
the caching process packages the at least partial transaction into the current block under the condition that the difference between the maximum transaction data amount of the current block and the packaged transaction data amount is not smaller than the data amount of the at least partial transaction in the transaction group, wherein the packaged transaction data amount is the data amount of the transaction packaged into the current block at the current moment.
5. The method of claim 4, wherein, in a case where the at least partial transaction comprises a plurality of transactions, the caching process wraps the at least partial transaction to the current tile, comprising:
and the caching process sequentially packages each transaction to the current block according to the pre-execution sequence of the transactions.
6. The method of claim 1, the pre-execution process pre-executing a first transaction dependent on tile information of a tile being packed, comprising:
the pre-execution process calls the block information of the block being packed through a preset application programming interface, and pre-executes the first transaction according to the block information.
7. The method of claim 1, the caching process determining the tile information relied upon during pre-execution of a first transaction, comprising:
the caching process receives the block information sent by the pre-execution process in association with a first transaction; or,
and the caching process searches the block information corresponding to the first transaction according to the corresponding relation between the transaction maintained by the caching process and the block information relied on in the pre-execution process.
8. The method of claim 1, the caching process triggering the pre-execution process to re-pre-execute a first transaction in dependence upon first block information, comprising:
the caching process provides the first block information as context information for the first transaction to the pre-execution process for re-pre-execution of the first transaction by the pre-execution process in dependence on the first block information.
9. The method of claim 1, the first node further comprising a computing process,
The method further comprises the steps of: the pre-execution process sends a pre-execution read-write set and/or a pre-execution result of the first transaction to the cache process;
the caching process packages a first transaction into the current block, including: the caching process triggers the computing process to execute a first transaction, and an execution read-write set and/or an execution result of the first transaction returned by the computing process are obtained; and, the pre-execution read-write set at the first transaction is the same as the execution read-write set; and/or packing the first transaction into the current block under the condition that the pre-execution result of the first transaction is the same as the execution result.
10. The method of claim 1, further comprising:
the pre-execution process pre-executes a third transaction without depending on any block information, and sends the pre-executed third transaction to the caching process;
the caching process packages a third transaction to the current block.
11. The method of claim 1, wherein the block information of any block comprises a block height and/or a 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 pre-executes at least part of transactions in the transaction group according to the block information of the block being packed, and sends the pre-executed at least part of transactions to the cache process;
the caching process determines the block information relied on in the pre-execution process of the at least partial transaction, and determines the first block information of the current block which is being packaged at the current moment;
the caching process triggers the pre-execution process to re-pre-execute the at least part of transactions depending on the first block information under the condition that the block information is second block information different from the first block information;
and the caching process packages the at least partial transaction into the current block under the condition that the block information is the first block information.
13. The method according to claim 12,
the pre-execution process pre-executes at least part of the transactions in the transaction group in dependence upon the tile information of the tile being packaged, comprising: the pre-execution process pre-executes part of transactions in the transaction group depending on the block information of the block being packed;
the method further comprises the steps of: the pre-execution process pre-executes the rest of the transactions except the part of the transactions in the transaction group without relying on any block information, and sends the rest of the pre-executed transactions to the caching process.
14. The method of claim 13, the caching process packaging at least a portion of a transaction into the current block, comprising:
and the caching process packages all the transactions in the transaction group into the current block.
15. A block generation apparatus for use with a first node in a blockchain network, the first node including a caching process and a pre-execution process, the apparatus comprising:
the pre-execution unit is used for enabling the pre-execution process to pre-execute a first transaction according to the block information of the block being packed, and sending the pre-executed first transaction to the cache process;
the information determining unit is used for enabling the caching process to determine the block information which is dependent in the pre-execution process of the first transaction and determine the first block information of the current block which is being packaged at the current moment;
the re-pre-executing unit is used for enabling the caching process to trigger the pre-executing process to re-pre-execute the first transaction depending on the first block information under the condition that the block information is second block information different from the first block information;
and the transaction packaging unit is used for enabling the caching process to package the first transaction into the current block under the condition that the block information is the first block information.
16. A block generation apparatus for use with a first node in a blockchain network, the first node including a caching process and a pre-execution process, the apparatus comprising:
the pre-execution unit is used for enabling the pre-execution process to pre-execute at least part of transactions in the transaction group according to the block information of the block being packed, and sending the pre-executed at least part of transactions to the cache process;
the information determining unit is used for enabling the caching process to determine the block information which is dependent in the pre-execution process of the at least partial transaction and determine the first block information of the current block which is being packaged at the current moment;
a re-pre-execution unit, configured to cause the caching process to trigger the pre-execution process to re-pre-execute the at least part of the transaction depending on the first block information, if the block information is second block information different from the first block information;
and the transaction packaging unit is used for enabling the caching process to package the at least partial transaction into the current block under the condition that the block information is the first block information.
17. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
Wherein the processor is configured to implement the method of any one of claims 1-14 by executing the executable instructions.
18. A computer readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the steps of the method of any of claims 1-14.
CN202211736019.3A 2022-12-30 2022-12-30 Block generation method and device Pending CN116204335A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211736019.3A CN116204335A (en) 2022-12-30 2022-12-30 Block generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211736019.3A CN116204335A (en) 2022-12-30 2022-12-30 Block generation method and device

Publications (1)

Publication Number Publication Date
CN116204335A true CN116204335A (en) 2023-06-02

Family

ID=86512168

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211736019.3A Pending CN116204335A (en) 2022-12-30 2022-12-30 Block generation method and device

Country Status (1)

Country Link
CN (1) CN116204335A (en)

Similar Documents

Publication Publication Date Title
US20200265009A1 (en) Blockchain-based data migration method and apparatus
CN113743941B (en) Method for executing transaction in block chain, block chain and main node
KR20190091484A (en) Blockchain consensus method and device
TWI767106B (en) Method, device and device for configuring payment process and executing payment process
WO2021000570A1 (en) Model loading method and system, control node and execution node
CN114827165B (en) Method and block link point for grouping multiple transactions
CN113743942B (en) Transaction execution method, blockchain, master node and master storage device
CN111383031B (en) Intelligent contract execution method and system in block chain and electronic equipment
WO2024001024A1 (en) Method for executing transaction in blockchain system, and blockchain system and nodes
WO2023160085A1 (en) Method for executing transaction, blockchain, master node, and slave node
WO2020143410A1 (en) Data storage method and device, electronic device and storage medium
WO2023160083A1 (en) Method for executing transactions, blockchain, master node, and slave node
CN111913807B (en) Event processing method, system and device based on multiple storage areas
CN113744062A (en) Method for performing transactions in a blockchain, blockchain node and blockchain
WO2024001025A1 (en) Pre-execution cache data cleaning method and blockchain node
CN112596669A (en) Data processing method and device based on distributed storage
CN116707891A (en) Replay attack checking method and block link point
CN116204335A (en) Block generation method and device
CN112800057B (en) Fingerprint table management method and device
CN115033350A (en) Execution method and device of distributed transaction
CN107645541B (en) Data storage method and device and server
KR102365261B1 (en) A electronic system and operating method of memory device
CN118277344B (en) Storage node interlayer merging method and device of distributed key value storage system
US11645200B2 (en) Reducing load balancing work stealing
CN116821242A (en) Block synchronization method, device and block chain system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination