TRANSACTION CONFIRMATION METHODS AND APPARATUSES IN BLOCKCHAIN NETWORK
Embodiments of this specification provide transaction confirmation methods and apparatuses. An example method includes: in response to detecting an event indicating that one of multiple nodes has persistently stored a batch of transactions or executed transactions of a subbatch of transactions, determining a current latest subbatch of subbatches of transactions for which the multiple nodes have confirmed; determining a target subbatch according to the current latest subbatch; determining a first quantity of the multiple nodes that have generated execution results that are consistent with an execution result of the target subbatch; determining a second quantity of the multiple nodes that have persistently stored a target batch to which the target subbatch belongs; and in response to the first quantity and the second quantity both meeting a consensus fault tolerance, determining that transactions in the target subbatch are confirmable transactions.
The present application is based on and claims priority to Chinese Patent Application No. 202010889845.6 filed on Aug. 28, 2020 and titled “TRANSACTION CONFIRMATION METHODS AND APPARATUSES IN BLOCKCHAIN NETWORK”, the entire contents of which are incorporated herein by reference.
TECHNICAL FIELDOne or more embodiments of this specification relate to the field of blockchain technologies, and in particular, to transaction confirmation methods and apparatuses in a blockchain network.
BACKGROUNDA blockchain technology is a new application mode of using computer technologies such as point-to-point transmissions, consensus mechanisms, and encryption algorithms to implement distributed data storage. In a blockchain network, data can be stored and recorded through transactions. In early blockchain networks, only transfer transactions are supported. An increasing number of blockchain platforms support smart contracts to execute more varied transactions. In this way, the blockchain platforms allow users to execute transactions with more varied content to provide more varied functions.
SUMMARYA transaction confirmation mechanism is described in one or more embodiments of this specification, to reduce a transaction confirmation delay, enhance user experience, ensure throughput of a platform, and improve performance of the platform.
Embodiments of the present disclosure provide a transaction confirmation method in a blockchain network. The method can be implemented by a first node in the blockchain network. The method can include: in response to detecting an event indicating that one of the multiple nodes has persistently stored a batch of transactions or executed transactions of a subbatch of transactions, determining, by the first node, a current latest subbatch of subbatches of transactions for which the multiple nodes have confirmed; determining, by the first node, a target subbatch according to the current latest subbatch; determining, by the first node, a first quantity of the multiple nodes that have generated execution results that are consistent with an execution result of the target subbatch in the first node; determining, by the first node, a second quantity of the multiple nodes that have persistently stored a target batch to which the target subbatch belongs; and in response to the first quantity and the second quantity both meeting a consensus fault tolerance, determining, by the first node, that transactions in the target subbatch are confirmable transactions.
In some embodiments, the first node includes a persistent consensus list, a flow execution list, and a largest confirmation list, the persistent consensus list records latest batch information of a persistently stored transaction batch in each of the multiple nodes, the flow execution list records, for each of the multiple nodes, an execution result a transaction subbatch in the transaction batch on which a consensus is reached, and the largest confirmation list records latest subbatch information confirmed in the first node.
In some embodiments, the method further comprises: in response to the first quantity and the second quantity both meeting the consensus fault tolerance, updating the current latest subbatch with the target subbatch.
In some embodiments, the first event comprises receiving a first message from another node in the multiple nodes, the first message includes latest transaction batch information for which the other node completes persistent storing, and the method further comprises: updating the persistent consensus list with the latest transaction batch information in the first message.
In some embodiments, the first event comprises receiving a second message from another node of the multiple nodes, wherein the second message includes an execution result of a newly added transaction subbatch by the other node, and the method further comprises: updating the flow execution list with the execution result of the newly added transaction subbatch in the second message.
In some embodiments, the persistent consensus list comprises a first entry corresponding to the first node, and the method further comprises: acquiring, from a volatile storage of the first node, a first batch on which a consensus is reached, wherein the first batch is a next transaction batch following a batch recorded in the first entry; initiate persistent storing on the first batch; and adding transactions in the first batch to an execution queue.
In some embodiments, the first event comprises updating records in the first entry with the first batch in response to the persistent storing of the first batch being completed.
In some embodiments, the method further comprises: broadcasting a third message to one or more other nodes of the multiple nodes in response to the first event being detected, wherein the third message includes information on the first batch for the one or more other nodes to update persistent consensus lists in the one or more other nodes.
In some embodiments, the flow execution list comprises a second entry corresponding to the first node, and the first event comprises adding a first execution result of a first subbatch in the first batch to the second entry when the first execution result is generated.
In some embodiments, the method further comprises: broadcasting a fourth message to one or more other nodes of the multiple nodes in response to the first event being detected, wherein the fourth message includes information on the first execution result for the one or more other nodes to update flow execution results in the one or more other nodes.
In some embodiments, the execution result of the transaction subbatch comprises a hash value of the execution result of the transaction subbatch.
In some embodiments, the latest batch information is the largest batch number, and the determining a second quantity of the multiple nodes that have persistently stored a target batch to which the target subbatch belongs comprises: based on the persistent consensus list, determining, as the second quantity, a quantity of nodes whose largest batch numbers are greater than or equal to a batch number of the target batch.
In some embodiments, in response to determining that transactions in the target subbatch are confirmable transactions, the method further comprises: for any first transaction in the target subbatch, determining whether the first transaction is a local transaction, wherein the local transaction is a transaction directly received by the first node from a user client; and in response to a determination that the first transaction is a local transaction: determining a first user client corresponding to the first transaction, and sending a first confirmation message to the first user client, wherein the first confirmation message is used to indicate that the first transaction has been accurately executed.
In some embodiments, the first confirmation message comprises a transaction identifier of the first transaction, execution results of all transactions in the target subbatch, and signatures of the nodes of the first quantity.
In some embodiments, a quantity of transactions in the transaction batch is less than a quantity of transactions included in one block, and the method further comprises: in response to all transactions in a plurality of transaction batches are determined as confirmable transactions, forming a block based on the plurality of transaction batches.
Embodiments of this specification further provide a system comprising one or more processors and one or more non-transitory computer-readable memories coupled to the one or more processors and configured with instructions executable by the one or more processors to cause the system to perform operations in a blockchain network implemented by a first node of multiple nodes in the blockchain network, the operations comprising: in response to detecting an event indicating that one of the multiple nodes has persistently stored a batch of transactions or executed transactions of a subbatch of transactions, determining, by the first node, a current latest subbatch of subbatches of transactions for which the multiple nodes have confirmed; determining, by the first node, a target subbatch according to the current latest subbatch; determining, by the first node, a first quantity of the multiple nodes that have generated execution results that are consistent with an execution result of the target subbatch in the first node; determining, by the first node, a second quantity of the multiple nodes that have persistently stored a target batch to which the target subbatch belongs; and in response to the first quantity and the second quantity both meeting a consensus fault tolerance, determining, by the first node, that transactions in the target subbatch are confirmable transactions.
Embodiments of this specification further provide one or more non-transitory computer-readable storage media storing instructions executable by one or more processors, wherein execution of the instructions causes the one or more processors to perform operations in a blockchain network implemented by a first node of multiple nodes in the blockchain network, the operations comprising: in response to detecting an event indicating that one of the multiple nodes has persistently stored a batch of transactions or executed transactions of a subbatch of transactions, determining, by the first node, a current latest subbatch of subbatches of transactions for which the multiple nodes have confirmed; determining, by the first node, a target subbatch according to the current latest subbatch; determining, by the first node, a first quantity of the multiple nodes that have generated execution results that are consistent with an execution result of the target subbatch in the first node; determining, by the first node, a second quantity of the multiple nodes that have persistently stored a target batch to which the target subbatch belongs; and in response to the first quantity and the second quantity both meeting a consensus fault tolerance, determining, by the first node, that transactions in the target subbatch are confirmable transactions.
For the method and apparatus provided in the embodiments of this specification, consensus is initiated in batches, and a flow execution result is summarized in subbatches with fewer transactions to confirm a transaction, thereby reducing a consensus wait time, an execution wait time, and a confirmation wait time of a transaction, to significantly reduce a transaction confirmation delay. In addition, in the foregoing solution, in a manner of separating persistence and transaction execution in parallel, persistence overheads are concealed, thereby reducing the impact of a small batch of consensus on the TPS of a platform and ensuring TPS performance of the platform.
To describe the technical solutions in the embodiments of this specification or in the existing technologies more clearly, the following briefly describes the accompanying drawings required for describing the embodiments or the existing technologies. Apparently, the accompanying drawings in the following description show merely some of the embodiments of this specification, and a person of ordinary skill in the art may still derive other drawings from the accompanying drawings.
The solutions provided in this specification are described below with reference to the accompanying drawings.
A blockchain network may be formed by a plurality of nodes. These nodes can generate a new block by using a consensus mechanism in order to perform a transaction in the block. At least a portion of these nodes may be used as servers or blockchain platforms to interact with users. A user can send a transaction using such a platform node. The platform node can broadcast the transaction of the user in the blockchain network, for the nodes in the blockchain network to reach a consensus on the transaction and accurately execute the transaction. After the transaction is accurately executed, the platform node can return, to the user, an execution result of the transaction by the blockchain network. This is referred to as transaction confirmation. The time taken for the user to send the transaction and the platform node to return the execution result of the transaction by a blockchain system to the user is referred to as a transaction confirmation delay.
The transaction confirmation delay is closely related to the user experience. If the user fails to receive transaction confirmation information in time after sending the transaction, the user's experience of using the blockchain platform may be significantly reduced. However, reduction of the transaction confirmation delay can conflict with high throughput (e.g., transactions per second (TPS)) of the blockchain platform, and it is difficult to ensure performance in both aspects.
Therefore, it is desirable to provide an effective solution that can reduce a transaction confirmation delay without impairing throughput of the blockchain platform, thereby enhancing user experience and improving performance of a blockchain platform.
As shown in
In some embodiments, each node can maintain a transaction pool locally, place a received transaction in the transaction pool, and broadcast the received transaction to other nodes. As shown in
Each node may perform local persistent storing of a transaction block on which consensus is reached, and transactions in the transaction block on which consensus is reached may be sequentially performed in order to keep consistent data content recorded in nodes of the entire network. For the foregoing transaction Tx1 shown in
As can be seen from the foregoing process, factors that affect a transaction confirmation delay can include a consensus wait time, a network delay in consensus, a persistence delay in consensus, a delay of waiting for a transaction to be executed, a transaction execution delay, and a delay of waiting for a transaction to be confirmed.
In another aspect, factors that affect a transaction throughput (e.g., TPS) of the platform can include a consensus time, a transaction execution time, and a transaction result persistence time. Generally, when an average consensus time and an average persistence time of a unit transaction are shorter, the TPS of the platform is larger. It is appreciated that the persistence time may not be significantly affected by the size of content being made persistent, but may be closely related to a number of times in performing persistent storing. For example, when information of 10 k and 100 k are persistently stored, and a time required for storing the information of 10 k and a time required for storing the information of 100 k may be quite close. However, if each time information of 10 k is persistently stored and the recording is performed ten times, a total time is much longer than a time of persistently storing information of 100 k once. Therefore, users and systems usually increase a quantity of consensus transactions in one batch to reduce time costs for consensus and persistent storing of each transaction, thereby increasing the TPS. For example, in some solutions, consensus is reached in blocks. According to the settings of different blockchain systems, one block usually includes hundreds of transactions (for example, 300 transactions). In this way, the hundreds of transactions share time costs for consensus and persistent storing together.
However, if the quantity of consensus transactions in one batch is relatively large, delays of waiting for a transaction to be executed and waiting for the transaction to be confirmed are increased, resulting in an increase in a total delay for confirming the transaction. For example, if a transaction is located near the top in a consensus block (for example, near the first few transactions of 300 transactions in the consensus block), the transaction can be confirmed only after the 300 transactions in this block have been executed. For a transaction near the end in a consensus block, because transactions need to be sequentially executed, this transaction usually can be executed only after all transactions in front of the transaction have been executed, and a delay of waiting for the transaction to be executed is relatively long.
Therefore, conventionally, an increase in throughput (e.g., in TPS) conflicts with reduction of a transaction confirmation delay, and it is very difficult for the platform to ensure performance in both aspects.
In consideration of the foregoing issues, embodiments of this specification provide improved solutions. The solutions may reduce transaction confirmation delay while minimizing the impact on the TPS. To reduce a consensus wait time of a transaction, ways of improving the frequency of consensus, reducing a consensus interval, and reducing the quantity of consensus transactions in one batch may be adopted to improve delay performance. An increase in the frequency of consensus can cause an increase in persistence overheads in a consensus process. To prevent a synchronous wait for persistent storing during consensus of a small batch from impairing the throughput of the system, embodiments of this specification provide ways for implementing persistent storing and transaction execution in parallel in order to conceal persistence overheads. To further reduce the delay waiting for a transaction to be executed and the delay of waiting for a transaction to be confirmed in one consensus batch, embodiments of this specification further provide a flow confirmation process. That is, in one consensus batch, a transaction execution result may be summarized in subbatches of smaller quantities of transactions. When transaction execution of a subbatch meets a preset condition, a transaction in the subbatch may be confirmed, thereby further reducing the transaction confirmation delay.
In some embodiments, a consensus process of each transaction batch may be classified as a volatile consensus and a persistent consensus. When nodes reach, according to a consensus protocol, an agreement on transactions to be executed and an execution order of the transactions, the nodes may acquire a list of transactions on which the agreement is reached. In some embodiments, the list of transactions may be received from another node or may be determined locally according to a consensus algorithm. In this case, the list of transactions may be recorded in volatile storages (e.g., random-access memory, and cache) of the nodes, and such a state may be referred to as volatile consensus. Subsequently, the nodes make persistent or persistently store the transactions in the list that are in the volatile consensus state. After all the nodes have made persistent the transactions in the list, this batch of transactions may enter a persistent consensus state.
For ease of description below, the volatile consensus state is referred to as reaching consensus, consensus is reached, or variations thereof. When consensus is reached on a transaction batch, it means that consensus has been reached on the transaction batch but the persistent storing of the transaction batch is not completed.
In some embodiments, to conceal persistence overheads, once consensus is reached on a batch of transactions (e.g., a batch n of transactions in
In some embodiments, since the persistent storing and the flow execution are in parallel, to implement the foregoing concept of small batch of consensus and flow confirmation, data structures maintained by nodes may need to be updated.
As shown in
As discussed above, for the transaction batch on which a consensus is reached, the nodes separately persistently store the transaction batch. For example, for one node i, once the persistent storing of one transaction batch is completed, the node i records, in an entry corresponding to the current node i in the persistent consensus list, the latest transaction batch for which persistent storing has been currently completed. In addition, the latest largest transaction batch information is further broadcast to other nodes. In some embodiments, the node i also receives largest transaction batch information broadcast and reported by another node, thereby continuously updating the persistent consensus list in the node i.
As shown in
It is appreciated that that, the foregoing is a current state of the persistent consensus list recorded in the node 0. Due to other factors such as network delays, data content in a persistent consensus list recorded in another node and that in the node 0 may be different, but may have similar principles and structures.
As shown in
In some embodiments, the foregoing execution result of the transaction subbatch may be a variable value after the transactions are executed or may be a hash value obtained after hash operation is performed on the execution result.
As shown in
The foregoing is a current state of the flow execution list recorded in the node 0. Due to other factors such as network delays, data content in a flow execution list recorded in another node and that in the node 0 may be different, but may have similar principles and structures.
As shown in
Based on the transaction processing process shown in
As shown in
In some embodiments, the trigger event includes receiving a first message from another node, where the first message indicates updated largest transaction batch information for which the other node completes persistent storing. In response to receiving the first message, the first node needs to update the persistent consensus list. As a result, the first node's largest batch information corresponding to the other node is updated to the largest transaction batch information in the first message.
In some embodiments, the trigger event includes receiving a second message from another node, where the second message indicates an execution result of a newly added transaction subbatch by the other node. In response to receiving the second message, the first node needs to update the flow execution list, and the execution result of the newly added transaction subbatch by the other node is added to the flow execution list.
In some embodiments, the trigger event may be an update of a persistence status or a flow execution status of the first node by the first node. For example, it may be assumed that the first node currently has completed the persistent storing of an n-th batch. It is appreciated that the (volatile) consensus and persistence of the transaction may be performed in different threads in parallel. Therefore, it may be assumed that in this case, volatile consensus is reached on a plurality of subsequent batches. In this case, the first node may acquire, from a volatile storage, a next batch on which consensus is reached. For example, the next batch can be an (n+1)-th batch. Then, the first node can initiate persistent storing of the next batch. In addition, the first node can add transactions in the (n+1)-th batch to a to-be-executed transaction queue to sequentially execute the transactions and generate subbatch execution results.
Once the persistent storing of the foregoing (n+1)-th batch is completed, the first node updates largest batch information corresponding to the current node in the persistent consensus list with the (n+1)-th batch. Such an update also forms the trigger event. In addition, the first node further broadcasts the information of the (n+1)-th batch to one or more other nodes in a message form. The message broadcast by the first node can also be referred to as a third message. The third message allows the other nodes to update, according to the third message, persistent consensus lists maintained by the other nodes.
In some embodiments, in a process in which the first node executes a transaction on which a consensus is reached, every time a new subbatch execution result is generated, the newly generated subbatch execution result is added to the flow execution list and the entry corresponding to the first node in order to update the flow execution list. Such an update can also form the trigger event. In addition, the first node further broadcasts the newly generated subbatch execution result to other nodes in a message form. The message broadcast by the first node can be referred to as a fourth message. The fourth message can allow the other nodes to update, according to the fourth message, flow execution lists maintained by the other nodes.
Returning to
For the target subbatch, in step 44, a first quantity M1 of nodes that generated execution results for the target subbatch that are consistent with the first node is determined based on the flow execution list. The first quantity M1 means that at least M1 nodes have generated and reported execution results for the target subbatch, and the execution results for the target subbatch by the M1 nodes are the same as the first node and the same as each other.
In addition, in step 45, a second quantity M2 of nodes that completed persistent storing for a target batch to which the target subbatch belongs is determined based on the persistent consensus list. In other words, M2 nodes have completed the persistent storing of the batch to which the target subbatch belongs. For example, when records are kept in batch numbers in the persistent consensus list, in step 45, a quantity of nodes whose largest batch numbers are greater than or equal to a batch number of the target batch may be determined for use as the second quantity M2.
It is appreciated that steps 44 and 45 may be performed in any appropriate order, or may be performed in parallel.
Next, in step 46, it is determined whether the first quantity and the second quantity both meet a consensus fault tolerance corresponding to N nodes. The consensus fault tolerance may be related to the consensus protocol used by the N nodes. For example, when a Byzantine Fault Tolerance (BFT) consensus protocol is used, provided that it is ensured that N≥3m+1, the accurate consistency of consensus can be ensured, where N is a total quantity of nodes, and m is a quantity of nodes that encounter one or more errors. The consensus fault tolerance can include consensus fault tolerance quantity that correspond to the N nodes in the BFT protocol may be obtained according to the foregoing formula and the quantity N of nodes. For example, when N is equal to 4, the consensus fault tolerance quantity is 3. That is, when three nodes in the four nodes generate consistent results, the accuracy of the results can be ensured. In a case of using another consensus protocol, the consensus fault tolerance quantity corresponding to the N nodes may be correspondingly determined. It is appreciated that the fault tolerance quantity can include different quantities for the first quantity and the second quantity.
If the first quantity and the second quantity both meet the consensus fault tolerance quantity, in step 47, transactions in the target subbatch are determined as confirmable transactions. In step 48, the current largest subbatch in the largest confirmation list is updated with the target subbatch. Subsequent subbatches can be sequentially used as the target subbatch, and the first quantity and the second quantity can be determined again.
Description is provided below with reference to a specific example. It is assumed that after the trigger event occurs, the persistent consensus list, the flow execution list, and the largest confirmation list in the node 0 are in a state that is similar to the data list shown in
In the example, in step 42, the read current largest subbatch is n25. In step 43, the next subbatch, that is, a first subbatch n31 in the third batch, is used as the target subbatch. In step 44, as shown in the flow execution list of
In step 45, as shown in the persistent consensus list of
Therefore, it may be obtained in step 46 that the first quantity M1 and the second quantity M2 both reach the consensus fault tolerance quantity. In this case, in step 47, transactions in the subbatch n31 are determined as confirmable transactions, and the current largest confirmed subbatch is updated to n31.
Next, a next subbatch n32 is used as the target subbatch. Similarly, in step 44, as shown in the flow execution list of
When a next subbatch n33 is used as the target subbatch, it may be obtained in step 44 that only two nodes have generated consistent execution results h33 for n33. Therefore, M1 is equal to 2. In this case, the consensus fault tolerance quantity is not met, and transactions in n33 may not be confirmed.
If n41 is used as the target subbatch, the corresponding first quantity is M1 being equal to 3, but only the node 0 and the node 2 have completed the persistent storing of the fourth batch. Therefore, the second quantity is M2 being equal to 2, and the consensus fault tolerance quantity is not met. Therefore, the subbatch n41 cannot be confirmed.
In the process shown in
In some embodiments, for the first node, any transaction in the confirmable transaction subbatch is referred to as a first transaction. The first node determines whether the first transaction is a local transaction. The local transaction is a transaction directly received by the first node from a user client. If the first transaction is a local transaction, the first node determines a first user client corresponding to the first transaction, and sends a confirmation message to the first user client. The confirmation message can be used to indicate that the first transaction has been accurately executed. It is appreciated that a user client can refer to a client terminal used by a user, or a user itself.
In some embodiments, the foregoing execution results of a subbatch that are reported by the nodes in a flow include transaction identifiers of transactions in the subbatch, transaction execution results, or signatures of nodes. Confirmation messages for the transactions may be generated based on the execution results of the subbatch. For example, a transaction identifier of the first transaction may be acquired from execution results of a subbatch including the first transaction that are reported by the nodes. Execution results and node signatures of all the transactions in the subbatch are included in a confirmation message for the first transaction. In this way, a client may verify the confirmation message based on the execution result and the node signature of the foregoing subbatch. In some embodiments, the confirmation message may optionally include information such as a batch number of a batch to which the first transaction belongs.
In some embodiments, when transactions in one subbatch are confirmed, the subbatch may enter a to-be-written state. As discussed above, a quantity of transactions in a consensus batch is usually less than a quantity of transactions included in one block, and a quantity of transactions in a subbatch is smaller. Therefore, when all transactions in a plurality of transaction batches are determined as confirmable transactions, the plurality of confirmed transaction batches may be written into a block.
In summary, consensus is initiated in batches, and a flow execution result is summarized in subbatches with fewer transactions to confirm a transaction, thereby reducing a consensus wait time, an execution wait time, and a confirmation wait time of a transaction. The transaction confirmation delay may be significantly reduced. In addition, since persistent storing and transaction execution can be processed in parallel, persistence overheads can be concealed, thereby reducing the impact of a small batch of consensus on the TPS of a platform and ensuring TPS performance of the platform.
In some embodiments, a transaction confirmation apparatus in a blockchain network is provided. The apparatus may be deployed in any first node in multiple nodes included in the blockchain network. The first node may be embodied as any device, platform or device cluster having computing and processing capabilities to function as a blockchain node. In addition, the first node can keep a persistent consensus list, a flow execution list, and a largest confirmation list. The persistent consensus list is used to record largest batch information for which each of the nodes completes persistent storing for a transaction batch on which consensus is reached. The flow execution list is used to record an execution result by each node of a transaction subbatch in the transaction batch on which consensus is reached. The largest confirmation list is used to record largest subbatch information confirmed in a current node.
The reading unit 71 can be configured to read a current largest subbatch from the largest confirmation list in response to detecting a trigger event. The trigger event is an event causing the persistent consensus list or the flow execution list to change.
The quantity determining unit 72 can be configured to sequentially use a subbatch following the current largest subbatch as a target subbatch, determine, based on the flow execution list, a first quantity of nodes that generate consistent execution results for the target subbatch, and determine, based on the persistent consensus list, a second quantity of nodes that complete persistent storing for a target batch to which the target subbatch belongs.
The transaction confirmation unit 73 can be configured to determine transactions in the target subbatch as confirmable transactions when the first quantity and the second quantity both meet a consensus fault tolerance quantity corresponding to the N nodes, and update the current largest subbatch with the target subbatch.
In some embodiments, the trigger event includes receiving a first message from another node, where the first message indicates updated largest transaction batch information for which the other node completes persistent storing; and largest transaction batch information corresponding to the other node is updated in the persistent consensus list in response to the first message.
In some embodiments, the trigger event includes receiving a second message from another node. The second message indicates an execution result of a newly added transaction subbatch by the other node. The execution result of the newly added transaction subbatch is added to the flow execution list in response to the second message.
In some embodiments, the persistent consensus list includes a first entry corresponding to the first node, and the apparatus further includes a consensus acquisition unit and a transaction processing unit (not shown).
The consensus acquisition unit can be configured to acquire, from a volatile storage, a first batch on which consensus is reached, The first batch is a next transaction batch following a batch recorded in the first entry.
The transaction processing unit can be configured to initiate persistent storing on the first batch, and add transactions in the first batch to an execution queue for sequential execution to generate a subbatch execution result.
In some embodiments, the trigger event includes updating records in the first entry with the first batch when the transaction processing unit completes the persistent storing of the first batch.
In some embodiments, the apparatus 700 may further include a first broadcast unit (not shown). The first broadcast unit is configured to broadcast a third message to other nodes of the N nodes after the trigger event is detected. The third message indicates that the largest transaction batch for which the first node completes persistent storing is updated to the first batch.
In some embodiments, the flow execution list includes a second entry corresponding to the first node, and the trigger event includes adding a first execution result of a first subbatch in the first batch to the second entry when the first execution result is generated.
In some embodiments, the apparatus 700 may further include a second broadcast unit (not shown). The second broadcast unit is configured to broadcast a fourth message to other nodes of the N nodes after the trigger event is detected. The fourth message indicates the first execution result generated by the first node for the first subbatch.
In some embodiments, the execution result of the transaction subbatch includes a hash value of the execution result of the transaction subbatch.
In some embodiments, the largest batch information is the largest batch number. The quantity determining unit 72 is configured to determine, as the second quantity in the persistent consensus list, a quantity of nodes whose batch numbers are among multiple largest batch numbers respectively corresponding to the multiple nodes that are greater than or equal to a batch number of the target batch.
In some embodiments, the apparatus 700 further includes a notification unit 74, The notification unit 74 is configured to determine, for any first transaction in the target subbatch, whether the first transaction is a local transaction. The local transaction is a transaction received by the first node from a user client. In some embodiments, the notification unit 74 is configured to: if the first transaction is a local transaction, determine a first user client corresponding to the first transaction, and send a first confirmation message to the first user client. The first confirmation message is used to indicate that the first transaction has been accurately executed.
In some embodiments, the first confirmation message includes a transaction identifier of the first transaction, execution results of all transactions in the target subbatch, and signatures of the nodes of the first quantity.
In some embodiments, a quantity of transactions in the transaction batch is less than a quantity of transactions included in one block. In some embodiments, the apparatus 700 further includes a block forming unit (not shown). The block form unit is configured to form a block based on the plurality of transaction batches when all transactions in a plurality of transaction batches are determined as confirmable transactions.
As shown in the apparatus 700, a transaction confirmation delay can be reduced, and TPS performance of the platform can be ensured.
Embodiments of this specification further provide a computer-readable storage medium storing computer executable instructions. The computer executable instructions, when executed by a processor, can cause the processor to perform the methods and the operations of the embodiments described herein.
The computer-readable medium includes a volatile medium and a non-volatile medium, a removable medium and a non-removable medium, which may implement storage of information by using any method or technology. The information may be a computer-readable instruction, a data structure, a module of a program, or other data. Examples of computer storage media include, but are not limited to, a phase change memory (PRAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), other type of random access memory (RAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory or other memory technology, a compact disc read-only memory (CD-ROM), a digital versatile disc (DVD) or other optical storage, a cassette magnetic tape, tape and disk storage or other magnetic storage device or any other non-transmission media that may be configured to store information that a computing device can access. Based on the definition in the present disclosure, the computer readable medium does not include transitory computer readable media (transitory media), such as a modulated data signal and a carrier.
In some embodiments, a computing device is further provided. The computing device includes a memory and a processor, The memory stores an executable code. The processor, when executing the executable code, can implement the foregoing described methods.
It may be learned from description of the foregoing implementations that, a person skilled in the art may clearly understand that the embodiments of this specification may be implemented by using software in addition to a necessary universal hardware platform. Based on such an understanding, the technical solutions of the embodiments of this specification essentially or the part contributing to the existing technologies may be implemented in a form of a software product. The computer software product may be stored in a storage medium, such as a ROM/RAM, a hard disk, or an optical disc, and includes a plurality of instructions for instructing a computer device (which may be a personal computer, a server, or a network device) to perform the methods described in the embodiments or some parts of the embodiments of this specification.
In this specification, the embodiments are described in a progressive manner Reference may be made to each other for the same or a similar part of the embodiments. Each embodiment focuses on a difference from other embodiments. Especially, apparatus and device embodiments are basically similar to a method embodiment, and therefore are described briefly; for related parts, refer to partial descriptions in the method embodiment. The method embodiment described above is merely an example. The modules described as separate parts may or may not be physically separate. During implementation of the solutions of the embodiments of this specification, the function of the modules may be implemented in the same piece of or a plurality of pieces of software and/or hardware. A part or all of the modules may be selected according to actual needs to achieve the objectives of the solutions of the embodiments. A person of ordinary skill in the art may understand and implement this specification without creative efforts.
It is appreciated that specific embodiments of this specification are described above. Other embodiments fall within the scope of the appended claims. In some cases, the actions or steps recorded in the claims may be performed in sequences different from those in the embodiments and an expected result may still be achieved. In addition, the processes depicted in the accompanying drawings is not necessarily performed in the specific order or successively to achieve an expected result. In some implementations, multitasking and parallel processing may be feasible or beneficial.
It is appreciated that an element described in a singular form herein or displayed only one in the accompanying drawings does not represent that the element is limited to one. In addition, modules or elements described or shown as separate herein may be combined into a single module or element, and a module or an element described or shown herein as a single module or element may be split into a plurality of modules or elements.
It is appreciated that the terms and expression manners used herein are merely for description, and one or more embodiments of this specification should not be limited to these terms and expressions. The use of these terms and expressions does not mean to exclude any equivalent features of the illustration and description (or part of them), and it should be understood that various modifications that may exist should also be included in the scope of claims. Other modifications, changes, and replacements may also exist. Accordingly, the claims should be considered as covering all these equivalents.
It is appreciated that although the descriptions are made with reference to current specific embodiments, a person of ordinary skill in the art should understand that the foregoing embodiments are only used for illustrating one or more embodiments of this specification. Various equivalent changes or substitutions may be made without departing from the spirit of this application. Therefore, changes and modifications to the foregoing embodiments within the essential spirit of this application shall fall into the scope of the claims of this application.
Claims
1. A method for transaction confirmation in a blockchain network implemented by a first node of multiple nodes in the blockchain network, the method comprising:
- in response to detecting an event indicating that one of the multiple nodes has persistently stored a batch of transactions or executed transactions of a subbatch of transactions, determining, by the first node, a current latest subbatch of subbatches of transactions for which the multiple nodes have confirmed;
- determining, by the first node, a target subbatch according to the current latest subbatch;
- determining, by the first node, a first quantity of the multiple nodes that have generated execution results that are consistent with an execution result of the target subbatch in the first node;
- determining, by the first node, a second quantity of the multiple nodes that have persistently stored a target batch to which the target subbatch belongs; and
- in response to the first quantity and the second quantity both meeting a consensus fault tolerance: determining, by the first node, that transactions in the target subbatch are confirmable transactions.
2. The method according to claim 1, wherein the first node includes a persistent consensus list, a flow execution list, and a largest confirmation list, the persistent consensus list records latest batch information of a persistently stored transaction batch in each of the multiple nodes, the flow execution list records, for each of the multiple nodes, an execution result a transaction subbatch in the transaction batch on which a consensus is reached, and the largest confirmation list records latest subbatch information confirmed in the first node.
3. The method according to claim 2, further comprising:
- in response to the first quantity and the second quantity both meeting the consensus fault tolerance, updating the current latest subbatch with the target subbatch.
4. The method according to claim 2, wherein the first event comprises receiving a first message from another node in the multiple nodes, the first message includes latest transaction batch information for which the other node completes persistent storing, and the method further comprises:
- updating the persistent consensus list with the latest transaction batch information in the first message.
5. The method according to claim 2, wherein the first event comprises receiving a second message from another node of the multiple nodes, wherein the second message includes an execution result of a newly added transaction subbatch by the other node, and the method further comprises:
- updating the flow execution list with the execution result of the newly added transaction subbatch in the second message.
6. The method according to claim 2, wherein the persistent consensus list comprises a first entry corresponding to the first node, and the method further comprises:
- acquiring, from a volatile storage of the first node, a first batch on which a consensus is reached, wherein the first batch is a next transaction batch following a batch recorded in the first entry;
- initiate persistent storing on the first batch; and
- adding transactions in the first batch to an execution queue.
7. The method according to claim 6, wherein the first event comprises updating records in the first entry with the first batch in response to the persistent storing of the first batch being completed.
8. The method according to claim 7, further comprising:
- broadcasting a third message to one or more other nodes of the multiple nodes in response to the first event being detected, wherein the third message includes information on the first batch for the one or more other nodes to update persistent consensus lists in the one or more other nodes.
9. The method according to claim 6, wherein the flow execution list comprises a second entry corresponding to the first node, and the first event comprises adding a first execution result of a first subbatch in the first batch to the second entry when the first execution result is generated.
10. The method according to claim 9, further comprising:
- broadcasting a fourth message to one or more other nodes of the multiple nodes in response to the first event being detected, wherein the fourth message includes information on the first execution result for the one or more other nodes to update flow execution results in the one or more other nodes.
11. The method according to claim 1, wherein the execution result of the transaction subbatch comprises a hash value of the execution result of the transaction subbatch.
12. The method according to claim 2, wherein the latest batch information is the largest batch number, and the determining a second quantity of the multiple nodes that have persistently stored a target batch to which the target subbatch belongs comprises:
- based on the persistent consensus list, determining, as the second quantity, a quantity of nodes whose largest batch numbers are greater than or equal to a batch number of the target batch.
13. The method according to claim 1, wherein in response to determining that transactions in the target subbatch are confirmable transactions, the method further comprises:
- for any first transaction in the target subbatch, determining whether the first transaction is a local transaction, wherein the local transaction is a transaction directly received by the first node from a user client; and
- in response to a determination that the first transaction is a local transaction: determining a first user client corresponding to the first transaction, and sending a first confirmation message to the first user client, wherein the first confirmation message is used to indicate that the first transaction has been accurately executed.
14. The method according to claim 13, wherein the first confirmation message comprises a transaction identifier of the first transaction, execution results of all transactions in the target subbatch, and signatures of the nodes of the first quantity.
15. The method according to claim 1, wherein a quantity of transactions in the transaction batch is less than a quantity of transactions included in one block, and the method further comprises:
- in response to all transactions in a plurality of transaction batches are determined as confirmable transactions, forming a block based on the plurality of transaction batches.
16. A system comprising one or more processors and one or more non-transitory computer-readable memories coupled to the one or more processors and configured with instructions executable by the one or more processors to cause the system to perform operations in a blockchain network implemented by a first node of multiple nodes in the blockchain network, the operations comprising:
- in response to detecting an event indicating that one of the multiple nodes has persistently stored a batch of transactions or executed transactions of a subbatch of transactions, determining, by the first node, a current latest subbatch of subbatches of transactions for which the multiple nodes have confirmed;
- determining, by the first node, a target subbatch according to the current latest subbatch;
- determining, by the first node, a first quantity of the multiple nodes that have generated execution results that are consistent with an execution result of the target subbatch in the first node;
- determining, by the first node, a second quantity of the multiple nodes that have persistently stored a target batch to which the target subbatch belongs; and
- in response to the first quantity and the second quantity both meeting a consensus fault tolerance: determining, by the first node, that transactions in the target subbatch are confirmable transactions.
17. The system according to claim 16, wherein the first node includes a persistent consensus list, a flow execution list, and a largest confirmation list, the persistent consensus list records latest batch information of a persistently stored transaction batch in each of the multiple nodes, the flow execution list records, for each of the multiple nodes, an execution result a transaction subbatch in the transaction batch on which a consensus is reached, and the largest confirmation list records latest subbatch information confirmed in the first node.
18. The system according to claim 17, wherein the operations further comprise:
- in response to the first quantity and the second quantity both meeting the consensus fault tolerance, updating the current latest subbatch with the target subbatch.
19. The system according to claim 16, wherein in response to determining that transactions in the target subbatch are confirmable transactions, the operations further comprise:
- for any first transaction in the target subbatch, determining whether the first transaction is a local transaction, wherein the local transaction is a transaction directly received by the first node from a user client; and
- in response to a determination that the first transaction is a local transaction: determining a first user client corresponding to the first transaction, and sending a first confirmation message to the first user client, wherein the first confirmation message is used to indicate that the first transaction has been accurately executed.
20. One or more non-transitory computer-readable storage media storing instructions executable by one or more processors, wherein execution of the instructions causes the one or more processors to perform operations in a blockchain network implemented by a first node of multiple nodes in the blockchain network, the operations comprising:
- in response to detecting an event indicating that one of the multiple nodes has persistently stored a batch of transactions or executed transactions of a subbatch of transactions, determining, by the first node, a current latest subbatch of subbatches of transactions for which the multiple nodes have confirmed;
- determining, by the first node, a target subbatch according to the current latest subbatch;
- determining, by the first node, a first quantity of the multiple nodes that have generated execution results that are consistent with an execution result of the target subbatch in the first node;
- determining, by the first node, a second quantity of the multiple nodes that have persistently stored a target batch to which the target subbatch belongs; and
- in response to the first quantity and the second quantity both meeting a consensus fault tolerance: determining, by the first node, that transactions in the target subbatch are confirmable transactions.
Type: Application
Filed: Jun 27, 2021
Publication Date: Mar 3, 2022
Patent Grant number: 11372849
Inventor: Xiaojian LIU (HANGZHOU)
Application Number: 17/359,619