WO2023184052A1 - 一种数据处理方法、区块链节点及区块链系统 - Google Patents

一种数据处理方法、区块链节点及区块链系统 Download PDF

Info

Publication number
WO2023184052A1
WO2023184052A1 PCT/CN2022/083235 CN2022083235W WO2023184052A1 WO 2023184052 A1 WO2023184052 A1 WO 2023184052A1 CN 2022083235 W CN2022083235 W CN 2022083235W WO 2023184052 A1 WO2023184052 A1 WO 2023184052A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
block
node
block height
transactions
Prior art date
Application number
PCT/CN2022/083235
Other languages
English (en)
French (fr)
Inventor
查君浩
罗玉龙
李湘识
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to PCT/CN2022/083235 priority Critical patent/WO2023184052A1/zh
Publication of WO2023184052A1 publication Critical patent/WO2023184052A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof

Definitions

  • This application relates to the field of data processing technology, specifically a data processing method, a blockchain node and a blockchain system.
  • Blockchain is a distributed ledger with a chained data structure that is composed of data blocks connected in a sequential manner. Blockchain has the advantages of decentralization, non-tampering, and traceability, and has broad application prospects in many fields.
  • the pre-execution (execute-order-validation, EOV) architecture blockchain has a read-write separation transaction process, which can provide better system performance and has been widely used.
  • isolation verification needs to be completed before transaction data is submitted to the chain. Therefore, whether isolation verification can be completed efficiently will have a significant impact on the performance of the blockchain system.
  • the embodiments of this application provide a data processing method, a blockchain node and a blockchain system, which can improve the performance of the blockchain system.
  • a data processing method is provided, which is applied to the first node in the blockchain system.
  • the method includes: obtaining the read set of the first transaction, and obtaining the first block height.
  • the first block height is When endorsing the first transaction, the maximum block height in the blockchain system, the cache of the first node stores the write sets included in multiple dropped blocks in the blockchain system, and multiple dropped blocks.
  • the block height corresponding to the placed block; when the first block height is within the range of the block heights corresponding to multiple placed blocks, based on the read set of the first transaction, it is compared with the multiple placed blocks Included in the write-up is the legality of the first transaction.
  • the read set of a transaction refers to the key (key) and key value (value) read by the endorsement node when it simulates execution or pre-execution of the transaction (that is, the transaction endorsement).
  • the write set refers to the data generated after the transaction is simulated or pre-executed, including keys and key values.
  • the key may specifically indicate an account
  • the corresponding key value may indicate the account balance. Then the key value in the read set refers to the account balance before the transaction is simulated or pre-executed, and the key value in the write set refers to the account balance after the transaction is simulated or pre-executed.
  • the essence of verifying the legality of the first transaction is: when the block including the first transaction is placed, determine whether the first transaction has been modified by the exchange in the block that has been placed, That is, whether the read set of the first transaction conflicts with the write set of the transaction in the placed block.
  • the placement time of the transaction that may modify the read set of the first transaction is after the endorsement of the first transaction. Therefore, when the block including the first transaction is placed, the legality verification of the first transaction requires finding or determining the placed block that was placed after the endorsement of the first transaction, and using the placed block Write set in the disk block to verify the legality of the first transaction.
  • the identified or determined placed block after the first transaction endorsement specifically refers to: the placed block within the time period from the time of the first transaction endorsement to the placement of the block containing the first transaction. disk block.
  • the embodiment of the present application uses the block height to represent the timestamp, and uses the block height interval to represent the time period.
  • the block height refers to the distance between the block and the genesis block (the first block of the blockchain) in the blockchain. number of blocks.
  • the block height can be used as the number of the block on the blockchain to identify the block. You can query the block based on its block height.
  • the maximum block height represents the latest block to be concatenated or placed on the blockchain. That is, the maximum block height refers to the latest block to be concatenated to the blockchain. high.
  • the value of the maximum block height is equal to the number of concatenated blocks on the blockchain.
  • the maximum block height of a blockchain changes as the number of blocks connected to the blockchain increases.
  • the minimum block height represents the first block on the blockchain, the genesis block. In addition, it should be pointed out that, generally speaking, in a blockchain system, the minimum block height is 0, not 1. In other words, the block height starts counting from 0.
  • the blockchain system described in the embodiments of this application can maintain or record one blockchain or multiple blockchains.
  • the block height mentioned is the block height on the same blockchain.
  • the first block height refers to the maximum block height of blockchain G1 when the first transaction is endorsed. Multiple blocks have been placed.
  • a block refers to a block that has been concatenated or placed on blockchain G1.
  • the block height of multiple placed blocks is the block height of blockchain G1.
  • the block height of a certain block represents the placement time of the block.
  • the placement time of different blocks is different, and the block height is also different. different.
  • a block height can be understood as or represents a specific moment, and the maximum block height of the blockchain represents the current moment.
  • the maximum block height changes accordingly, which is equivalent to the flow of time forward. That is, changes in the maximum block height can represent changes in time. Therefore, the maximum block height when the first transaction is pre-executed (i.e., the first transaction endorsement) can represent when the first transaction was endorsed, that is, when the read set of the first transaction was read. of.
  • each block height corresponding to multiple placed blocks represents when the corresponding block was placed. If the maximum block height of the blockchain system at the time of the first transaction endorsement falls within the block height range corresponding to multiple placed blocks, it means that the blocks placed after the first transaction endorsement are included in the block height range. placed blocks. In this way, the legitimacy of the first transaction can be obtained by using the write-set of transactions in the multiple placed blocks.
  • the data processing method provided by the embodiment of this application can determine whether the maximum block height at the time of the first transaction endorsement falls within the block height range corresponding to multiple placed blocks. It can be obtained that after the first transaction endorsement Whether the dropped block is included in the multiple dropped blocks, that is, whether it is included in the cached data. If it is included in the cached data, the data in the cache can be used to complete the legality verification of the first transaction. Therefore, through the method provided by the embodiments of this application, the first node can use the data in the cache to complete the legality verification of the first transaction without obtaining data from the state database, which can reduce the time required for the legality verification of the first transaction. Reduce the delay in uploading the first block to the chain and improve the performance of the blockchain system.
  • the first node performs legality verification on the first transaction through the method provided by the embodiment of this application, so that the legality verification is less affected by the data scale in the first node's state database, and the speed of legal verification does not change with the status.
  • the changes in the size of the data in the database ensure the performance stability of the long-term operation of the blockchain system.
  • the first node uses the data in the cache to verify the legality of the first transaction, avoiding or reducing the memory usage of the legality verification and reducing the impact on the state database. .
  • the communication overhead between the processor and the memory can be reduced and hardware resources can be saved.
  • the block heights corresponding to the multiple placed blocks belong to the interval [B h -n+1, B h ], then when the first block height is greater than or equal to B h -n+ At 1, the first block height is within the range of block heights corresponding to multiple placed blocks, where n is an integer greater than or equal to 1, and B h is an integer greater than or equal to 0.
  • the multiple placed blocks may be n placed blocks with block heights distributed as B h -n+1, B h -n+2, ..., B h . Comparing the first block height (i.e., the largest block height in the blockchain system when endorsing the first transaction) and the block height of the block with the smallest block height among multiple placed blocks, we can get Transactions that may modify the read set of the first transaction are included in the multiple placed blocks, so that the write sets included in the multiple placed blocks can be used to verify the legality of the first transaction, ensuring that the first transaction is The completeness of the legality verification of a transaction.
  • first block height i.e., the largest block height in the blockchain system when endorsing the first transaction
  • B h the block height of the block with the smallest block height among multiple placed blocks
  • B h is the maximum block height in the blockchain system when the block to which the first transaction belongs is generated.
  • multiple placed blocks include the maximum block height in the blockchain system when the block to which the first transaction belongs is generated, thus avoiding the omission of transactions that may modify the read set of the first transaction. , ensuring the completeness of the first transaction legality verification.
  • the method further includes: when the first block height is not within the range of block heights corresponding to multiple placed blocks, obtaining the first block height from the status database of the first node.
  • the first key value of the key corresponding to the read set of a transaction based on the read set of the first transaction and the first key value, the legitimacy of the first transaction is obtained.
  • the read set includes keys and key values.
  • the key corresponding to the read set here refers to the key in the read set.
  • the first block height is not within the range of block heights corresponding to multiple placed blocks, it means that the transactions that may modify the first transaction read set may not be included in the multiple placed blocks. in the disk block.
  • the key value corresponding to the read set of the first transaction is obtained from the state database, and the key value is used to verify the legality of the first transaction.
  • the key value of a key in the state database is the latest key value of the key.
  • the blockchain node specifically, the ledger node
  • the key value obtained from the state database for a key is usually the latest key value for that key. Therefore, obtaining the key value corresponding to the read set of the first transaction from the state database, and performing legality verification on the first transaction accordingly, can ensure the completeness of the legality verification of the first transaction.
  • the blockchain system further includes a first endorsement node and a second endorsement node for endorsing the first transaction, and obtaining the first block height includes: obtaining the second block height and the second endorsement node.
  • the larger of the maximum block heights for multiple endorsements is used.
  • the smaller one or the smallest one is used to determine the block used to verify the legitimacy of the first transaction, which can avoid or reduce the risk of incorrect verification results caused by the fraud of some endorsement nodes.
  • the method further includes: obtaining a read set of the second transaction, the first transaction and the second transaction belong to the same block; in the read set based on the first transaction, and multiple dropped disks
  • the read set based on the second transaction is executed in parallel to obtain the legality of the second transaction.
  • the second transaction may be all other transactions or part of other transactions except the first transaction in the block to which the first transaction belongs.
  • the first node while using the cached data to verify the legality of the first transaction, the first node can also verify the legality of other transactions. That is to say, the legality verification of multiple transactions can be executed concurrently, thereby further reducing the time required to complete the legality verification of transactions in the entire block, further reducing the delay in uploading the block to the chain, and improving the efficiency of the blockchain system. performance.
  • the legality verification of all transactions in the block to which the first transaction belongs can be executed concurrently, thus greatly reducing the delay in uploading the block to the chain and improving the performance of the blockchain system.
  • the legality verification of some transactions in the block to which the first transaction belongs can also be executed concurrently.
  • obtaining the legality of the first transaction based on the read set of the first transaction and the write sets included in multiple placed blocks includes: comparing the read set of the first transaction with If the write set of the third transaction conflicts, the first transaction is illegal and the third transaction is included in multiple placed blocks.
  • the read set of the first transaction conflicts with the write set of the third transaction, that is, the read set of the first transaction conflicts with the write set of the transaction in the placed block, the first transaction will be deemed illegal, thereby protecting the blockchain system. consistency of the data.
  • obtaining the legality of the first transaction based on the read set of the first transaction and the write sets included in multiple placed blocks includes: When the write sets included in the placed block do not conflict, the legitimacy of the first transaction is obtained based on the read set of the first transaction and the write sets of other transactions, where the other transactions are the blocks to which the first transaction belongs. transactions other than the first transaction.
  • obtaining the legality of the first transaction based on the read set of the first transaction and the write set of other transactions includes: in the case that the first transaction does not depend on the write set of other transactions, the first transaction Legal; or, when the first transaction depends on the write set of the fourth transaction in other transactions, and the fourth transaction is illegal, the first transaction is legal; or, when the first transaction depends on the fourth transaction among other transactions, Write set, and the fourth transaction is legal, the first transaction is illegal.
  • the first transaction when the read set of the first transaction does not depend on other transactions in the same block, or the dependent transaction is illegal, the first transaction can be determined to be legal.
  • the read set of the first transaction depends on other transactions in the same block and the transactions it relies on are legal, the first transaction can be determined to be illegal, thereby ensuring the consistency of data in the blockchain system.
  • a data processing method is provided, which is applied to the first node in the blockchain system.
  • the method includes: obtaining the read set of the first transaction and the read set of the second transaction, the first transaction and the second transaction. Belong to the same block; in the process of obtaining the legality of the first transaction based on the read set of the first transaction, the read set based on the second transaction is executed in parallel to obtain the legality of the second transaction.
  • the first transaction and/or the second transaction may include at least one transaction.
  • the first transaction and the second transaction constitute all transactions in the same block.
  • the first transaction and the second transaction may be partial transactions in the same block.
  • the legality of multiple transactions in the same block can be verified at the same time, thereby further reducing the time required to complete the legality verification of transactions in the entire block, further reducing the delay in uploading the block to the chain, and improving the efficiency of the district.
  • Performance of blockchain systems the legality verification of all transactions in the block to which the first transaction belongs can be executed concurrently, thereby greatly reducing the delay in uploading the block to the chain and improving the performance of the blockchain system.
  • the legality verification of some transactions in the block to which the first transaction belongs can also be executed concurrently.
  • the cache of the first node stores write sets included in multiple dropped blocks in the blockchain system, and block heights corresponding to the multiple dropped blocks; method It also includes: obtaining the first block height, which is the maximum block height in the blockchain system when endorsing the first transaction; obtaining the legality of the first transaction based on the read set of the first transaction, including : Based on the read set of the first transaction and the write set included in multiple placed blocks, the legitimacy of the first transaction is obtained.
  • the first node while using the cached data to verify the legality of the first transaction, the first node can also verify the legality of other transactions. That is to say, the legality verification of multiple transactions can be executed concurrently, thereby further reducing the time required to complete the legality verification of transactions in the entire block, further reducing the delay in uploading the block to the chain, and improving the efficiency of the blockchain system. performance.
  • the method further includes: obtaining a second block height, which is the maximum block height in the blockchain system when endorsing the second transaction; based on the second transaction
  • the read set to obtain the legality of the second transaction includes: the read set based on the second transaction and the write set included in multiple placed blocks to obtain the legality of the second transaction.
  • the first node while using the cached data to verify the legality of the first transaction, the first node can also use the cached data to verify the legality of other transactions. That is to say, the legality verification of multiple transactions can be executed concurrently, thereby further reducing the time required to complete the legality verification of transactions in the entire block, further reducing the delay in uploading the block to the chain, and improving the efficiency of the blockchain system. performance.
  • obtaining the legality of the second transaction based on the read set of the second transaction includes: obtaining the first key value of the key corresponding to the read set of the second transaction from the state database of the first node; Based on the read set of the second transaction and the first key value, the legality of the second transaction is obtained.
  • the first node while using cached data to verify the legality of the first transaction, can also use data obtained from the state database to verify the legality of other transactions. That is to say, the legality verification of multiple transactions can be executed concurrently, thereby further reducing the time required to complete the legality verification of transactions in the entire block, further reducing the delay in uploading the block to the chain, and improving the efficiency of the blockchain system. performance.
  • obtaining the legality of the first transaction based on the read set of the first transaction includes: obtaining the second key value of the key corresponding to the read set of the first transaction from the state database of the first node; Based on the read set of the first transaction and the second key value, the legality of the first transaction is obtained.
  • data is obtained from the state database to verify the legality of multiple transactions simultaneously. That is to say, the legality verification of multiple transactions can be executed concurrently, thereby further reducing the time required to complete the legality verification of transactions in the entire block, further reducing the delay in uploading the block to the chain, and improving the efficiency of the blockchain system. performance.
  • a data processing device including: a functional unit for implementing the method provided in the first aspect.
  • a blockchain node including a processor and a memory; the memory is used to store a computer program; and the processor is used to execute the computer program to implement the method provided in the first aspect.
  • the fourth aspect provides a blockchain system, which is characterized by including the blockchain node, endorsement node and ordering node provided in the fourth aspect.
  • a fifth aspect provides a computer storage medium, characterized in that a computer program is stored on the computer storage medium, and when the computer program is executed by a processor, the method provided in the first aspect is implemented.
  • embodiments of the present application provide a computer program product, including a program for implementing the method provided in the first aspect.
  • the solution provided by the embodiment of this application only requires some memory overhead and computing resources, and can quickly complete the isolation verification of transactions in the block to be uploaded, greatly reducing the time required to verify the isolation of transactions in the block to be uploaded. It speeds up the speed of blockchain uploading and improves the performance of the blockchain system. Moreover, this solution is less affected by the data size in the state database when performing isolation verification on transactions, so that the speed of isolation verification will not change with the increase in the data size in the state database, ensuring that the blockchain The performance stability of the system for long-term operation. In addition, this solution uses the data cached in the memory to perform isolation verification of transactions in the blocks to be uploaded to the chain, avoiding the occupation of memory by transaction isolation verification, reducing the impact on the state database, and speeding up the block upload. The speed of the chain helps the blockchain system run with high performance in complex business scenarios.
  • Figure 1 is a schematic structural diagram of a blockchain system provided by an embodiment of this application.
  • Figure 2 is a schematic diagram of transaction submission for parallel execution
  • Figure 3 is a flow chart of a transaction isolation verification method
  • Figure 4 is a schematic diagram of a data processing method provided by an embodiment of the present application.
  • Figure 5 is a schematic diagram of a transaction block that can modify the transaction read set in the block to be uploaded according to the embodiment of the present application;
  • Figure 6 is a flow chart of an isolation verification solution provided by an embodiment of the present application.
  • Figure 7A is a flow chart of an isolation verification solution provided by an embodiment of the present application.
  • Figure 7B is a flow chart of a data processing method provided by an embodiment of the present application.
  • Figure 8A is a flow chart of an isolation verification solution provided by an embodiment of the present application.
  • Figure 8B is a flow chart of a data processing method provided by an embodiment of the present application.
  • Figure 9 is a flow chart of a data processing method provided by an embodiment of the present application.
  • Figure 10 is a flow chart of a data processing method provided by an embodiment of the present application.
  • Figure 11 is a flow chart of a data processing method provided by an embodiment of the present application.
  • Figure 12 is a schematic structural diagram of a data processing device provided by an embodiment of the present application.
  • Figure 13 is a schematic diagram of a blockchain node structure provided by an embodiment of the present application.
  • Blockchain is a chain data structure composed of multiple data blocks connected in series.
  • Blockchain can be understood as a kind of ledger.
  • a data block in the blockchain is equivalent to a page in the ledger.
  • Data blocks, also referred to as blocks, record transaction data.
  • each block can contain information such as transaction data, timestamp, and the hash value of the previous block.
  • Blockchain technology can protect the information recorded in blocks with the help of cryptography. Based on blockchain technology, two or more parties can effectively record transaction data, making transaction data unforgeable and permanently verifiable.
  • the pre-execution architecture is a blockchain architecture.
  • the block chain needs to go through the transaction pre-execution (execute) step, the sorting (order) step and the verification (validate) step to ensure that it is recorded in the block. Consistency of transaction data.
  • Figure 1 shows a blockchain system under a pre-execution architecture.
  • the blockchain system may include at least one client node (eg client node 101), at least one endorsement node (eg endorsement node 102, endorsement node 103), at least one ordering node (eg ordering node 104) and at least one ledger node (For example, ledger node 105, ledger node 106).
  • client nodes when no special distinction is made between client nodes, endorsement nodes, ordering nodes, and ledger nodes, they may be referred to as blockchain nodes or nodes for short.
  • endorsing node 102 and the endorsing node 103 they may be simply called endorsing nodes.
  • ledger node 105 and the ledger node 106 they may be referred to as ledger nodes for short.
  • the blockchain system shown in Figure 1 can maintain or record one blockchain, or multiple blockchains.
  • the block heights mentioned are the block heights on the same blockchain.
  • blockchain nodes may be physical devices, such as servers or terminal devices.
  • blockchain nodes may be virtual devices.
  • virtual devices can be virtual machines (VMs), containers (containers) and other operating environments virtualized by software. This concept includes virtual machines and containers.
  • blockchain nodes may be processes or threads.
  • a process is a running activity of a program in a computer on a certain data set, and is the basic unit of resource allocation and scheduling in the system. Thread is the smallest unit that the operating system can perform operation scheduling. Threads are included in processes and are the actual operating units in processes.
  • Client nodes are entities that represent users. Client nodes can interact with other nodes in the blockchain system under the user's operation, such as initiating transactions, creating smart contracts in the blockchain system, etc. Taking initiating a transaction as an example, the client node can construct an endorsement service request. The function of the endorsement service request is to request the endorsement node to call the smart contract to pre-execute or simulate the execution of the transaction, and to endorse the pre-execution result of the transaction. The client node can send an endorsement service request to the endorsement node.
  • Endorsement nodes can also be called contract execution nodes or contract pre-execution nodes.
  • the endorsement node can respond to the endorsement service request and call the smart contract to simulate the execution of the transaction.
  • the data key value is read.
  • the data key value includes key (key) and key value (value).
  • the key may represent an account and the key value may represent the balance in the account.
  • the key is x
  • the read data key value represents the balance in the accounts of both parties before the transaction is executed.
  • the keys and key values read can be called a read set.
  • the write set includes the written data key values.
  • the key represents the account and the key value represents the balance in the account.
  • the written data key value represents the balance in the accounts of both parties after the transaction is executed.
  • x and y represent the keys of both parties to the transaction
  • read sets and write sets can be collectively referred to as read-write sets.
  • the read set can also be called a read-write set
  • the write set can also be called a read-write set.
  • a read-write set can refer to a read set and a write set, or a read set or a write set.
  • the read-write set adopts a preset data structure, including field F1 used to fill the read set and field F2 used to fill the write set. That is, field F1 and field F2 belong to or are included in the read-write set.
  • the data filled in field F1 can be called a read set
  • the data filled in field F2 can be called a write set.
  • the endorsing node signs the read-write set of the transaction and sends the signed read-write set to the client node.
  • multiple endorsement nodes are required to endorse a transaction.
  • the client node will receive signed read-write sets from multiple endorsing nodes.
  • the client node can encapsulate the read and write sets after receiving signatures from multiple endorsement nodes according to the preset data structure. This process can be called constructing transaction data.
  • the client node sends the encapsulated read-write set to the sorting node.
  • An ordering node which may also be called a consensus node, orders the read and write sets of multiple transactions received over a period of time.
  • the sorting node can determine the transaction sequence numbers of the multiple transactions based on the preset consensus algorithm, and sort the multiple transactions based on the transaction sequence numbers. Then, the sorted transaction read-write set and other related information are packaged into blocks, and the blocks are sent to the ledger node.
  • the ledger node can perform isolation verification on the read and write sets of transactions contained in the received blocks to ensure the independence of different transactions. Isolation means that when multiple users access the database concurrently, such as when operating the same table, the transactions opened by the database for each user (in the blockchain system, things refer to transactions) cannot be operated by other transactions. To avoid interference, multiple concurrent transactions must be isolated from each other. In this way, before the block is put on the chain (that is, connected to the blockchain or written into the ledger), the transactions in the block need to be isolated and verified, for example, multi-version concurrency control of the transactions in the block ( multi-version concurrency control (MVCC). Among them, for a transaction recorded in the block, when its isolation verification passes, the transaction can be marked as a legal transaction. When the transaction fails the isolation verification, the transaction can be marked as an illegal transaction.
  • MVCC multi-version concurrency control
  • transaction A1 is still marked as a legal transaction, then after the block containing the write set of transaction A1 is uploaded to the chain, the write set of transaction A1 will overwrite the write set of transaction A2 that was uploaded first, causing the write set of transaction A2 to be lost. Therefore, in order to avoid this situation, before the block is put on the chain, the read and write sets of the transactions contained in the block are isolated and verified.
  • the phenomenon that the read set of a transaction is inconsistent with the actual key value during isolation verification can be called a read set conflict of the transaction.
  • data is read from the state database of the ledger node to verify the isolation of transactions recorded in the blocks to be uploaded to the chain.
  • the state database of the ledger node stores the written set of transactions included in the blocks that have been uploaded to the chain, that is, the latest key values that have been confirmed by the blockchain system.
  • isolation verification includes two parts. One is to determine whether transactions in the same block have dependencies, and the other is to determine whether the read set of the transaction has been modified by the submitted transaction.
  • submitted transactions refer to transactions that have been uploaded to the chain, that is, submitted transactions are included in the blockchain.
  • the latest key value of the account corresponding to the transaction is obtained from the state database. Then, determine whether the latest key value of the account is consistent with the key value of the account in the transaction read set. If they are consistent, the read set of the transaction has not been modified by the submitted exchange, and the transaction is legal; if they are inconsistent, the transaction is illegal. Then, the isolation verification of the next transaction in the same block is performed until all transactions in the block are isolated.
  • the solution shown in Figure 3 needs to obtain data from the state database. As there are more and more blocks on the blockchain, more and more data is stored in the state database of the ledger node, resulting in the degradation of state database data retrieval and query performance. , causing isolation verification to take a longer time, thus affecting the performance of the blockchain system. Moreover, in the solution shown in Figure 3, the interaction between the verification execution unit and the database will bring processor and memory overhead. When there are a large number of blocks that need to be uploaded to the chain, the hardware resource overhead of the node is relatively large. As well as the solution shown in Figure 3, the isolation verification of multiple transactions in the block is executed serially, which results in a long time required to complete the isolation verification of the transactions in the entire block, which also affects the performance of the blockchain system. .
  • the embodiments of this application provide a data processing method.
  • the ledger node can cache n on-chain blocks, and use the write sets of transactions in the n on-chain blocks to verify the transactions in the blocks to be uploaded. Whether the read set conflicts with the write set of the transaction that has been uploaded to the chain, that is, it is judged whether the read set of the transaction in the block to be uploaded has been modified by the exchange that has been uploaded to the chain.
  • the block on the chain refers to the block that has been connected to the blockchain. That is, the block on the chain can also be called the placed block. It refers to the block that has been submitted and confirmed by the blockchain system. block.
  • On-chain transactions can also be called submitted transactions, which refer to transactions included in on-chain blocks.
  • the cached n blocks that have been uploaded to the chain refer to the n blocks that were recently uploaded to the chain relative to the time when the block to be uploaded is packaged. For example, set the packaging time of the block to be uploaded to the chain as time T1, the uploading time of the first block among the n blocks is closest to time T1, and the uploading time of the second block is and time T1 is only greater than the time between the on-chain time of the first block and time T1, and the time between the on-chain time of the third block and time T1 is only greater than that of the first block The time between the on-chain time and time T1, the time between the on-chain time of the second block and time T1, and so on.
  • Blocks to be uploaded refer to blocks that have not yet been connected to the blockchain and are about to be or are undergoing isolation verification. Transactions in blocks to be uploaded can be called transactions to be uploaded or transactions to be submitted. If the transactions in the block to be uploaded have completed isolation verification, the block can be uploaded to the chain, that is, connected to the blockchain.
  • block packaging can also be called consensus block production, which refers to packaging the read-write set and other related information of at least one transaction into blocks.
  • the block contains the read-write set and other related information of the transaction, which can be called: the block contains or includes transactions.
  • the ledger node can use the data in the cache to determine whether the read set of the transaction in the block to be uploaded conflicts with the write set of the transaction that has been uploaded to the chain.
  • the communication overhead between the processor and the memory is reduced and hardware resources are saved.
  • the n blocks that have been uploaded to the chain can be used to verify the isolation of multiple transactions at the same time. That is to say, the isolation verification of multiple transactions can be executed concurrently, thereby further reducing the need for the isolation of the entire block to be completed. The time required for verification further reduces the delay in uploading blocks to the chain and improves the transaction performance of the blockchain system.
  • the client node 101 can perform step 401 and send an endorsement service request to the endorsement node 102 and the endorsement node 103.
  • the endorsement node 102 can respond to the endorsement service request of transaction C1 sent by the client node 101 and pre-execute or simulate the execution of transaction C1. Among them, when the endorsement node 102 starts to pre-execute the transaction C1, it obtains the current maximum block height Sh1 of the endorsement node 102, obtains the read set of the transaction C1 based on the block height Sh1 , and based on the read set, pre-executes the transaction The contract business process is obtained by writing the set. Then the read-write set 22 of transaction C1 is obtained. The endorsement node 102 can sign the read-write set 22 and the block height Sh1 , that is, sign the signature 21 on the read-write set 22 and the block height Sh1 .
  • the signature 21, the read-write set 22 and the block height S h1 are sent to the client node 101 through 402a.
  • the process described above can be called the endorsement process of transaction C1 by the endorsement node 102.
  • the signature 21, the read-write set 22 and the block height S h1 can be collectively referred to as the endorsement result of the transaction C1 by the endorsement node 102.
  • pre-execution transaction the "contract business process of pre-execution transaction" may be referred to as pre-execution transaction for short.
  • the endorsement node 103 can also respond to the endorsement service request of transaction C1 sent by the client node 101 and pre-execute or simulate the execution of transaction C1.
  • the endorsement node 103 starts to pre-execute the transaction C1, it obtains the current maximum block height Sh2 of the endorsement node 103, obtains the read set of the transaction C1 based on the block height Sh2 , and based on the read set, pre-executes the transaction , get the writing set. Then the read-write set 32 of transaction C1 is obtained.
  • the endorsement node 103 can sign the read-write set 32 and the block height Sh2 , that is, sign the signature 31 on the read-write set 32 and the block height Sh2 .
  • the signature 31, the read-write set 32 and the block height Sh2 are sent to the client node 101 through 402b.
  • the process described above can be called the endorsement process of transaction C1 by the endorsement node 103.
  • Signature 31, read-write set 32 and block height Sh2 can be collectively referred to as the endorsement result of transaction C1 by endorsement node 103.
  • the endorsement node can also be used as a ledger node, which stores the blockchain, that is, the ledger is stored.
  • the blockchain can be obtained from the ledger node, or in other words, the ledger node can synchronize the blockchain with the endorsement node.
  • the ledger node can synchronize the blockchain containing the newly uploaded block to the endorsing node whenever a block is uploaded to the chain. In this way, the endorsing node can obtain the maximum block height of the endorsing node based on its own stored blockchain.
  • the current maximum block height of the endorsement node obtained when the endorsement node starts to pre-execute transaction C1 can be called the maximum block height at the time of endorsement of transaction C1.
  • one endorsement node can obtain the maximum block height for one endorsement
  • multiple endorsement nodes can obtain the maximum block height for multiple endorsements.
  • the client node 101 can receive endorsement results for transaction C1 sent by multiple endorsement nodes, and thus can receive multiple endorsement results for transaction C1, where multiple endorsement results correspond to multiple endorsement nodes one-to-one.
  • the client node 101 can construct transaction data based on the multiple endorsement results.
  • the client node 101 can first verify whether the read-write sets in multiple endorsement results are the same. If they are the same, that is, if the read-write sets in different endorsement results are the same, the client node 101 fills in the read-write set of transaction C1 into the preset fields in the data structure D1 according to the preset data structure D1. For example, since it has been verified that the read-write set of transaction C1 in different endorsement results is the same, one read-write set can be filled in the data structure D1, without filling in the read-write set in each endorsement result. This data structure is in D1.
  • the client node 101 can fill in the block height and signature in the endorsement result into corresponding fields in the data structure D1 (that is, correspondingly save or record the block height and signature from the same endorsement result).
  • the signature is used to indicate the legitimacy of the block height. Therefore, the signature and the block height need to be stored correspondingly.
  • the time at which different endorsing nodes start to pre-execute transaction C1 may be different, and the blockchains in different endorsing nodes at the same time may not be completely consistent. Therefore, the block height may be different in different endorsement results.
  • the block height and signature in each endorsement result can be correspondingly filled in the data result D1.
  • the client node 101 can complete the construction of the transaction data of the transaction C1. That is, the constructed transaction data includes the read-write set of transaction data including transaction C1, and the maximum block height when the endorsement node pre-executes the transaction (for example, the block height Sh1 when the endorsement node 102 pre-executes the transaction C1, and the endorsement node 103 pre-executes the transaction The block height Sh2 at C2), and the signature of the endorsing node.
  • the client node 101 can send the constructed transaction data of transaction C1 to the ordering node 104 through step 403.
  • the ordering node 104 can generate block B1, or consensus block, based on the transaction data of multiple transactions received in time period T2. Among them, the ordering node 104 can package the read-write sets and other related information of multiple transactions received in the time period T2 into block B1, that is, generate block B1.
  • the ordering node 104 may determine the transaction sequence number of each of the multiple transactions received in the time period T2 according to a preset consensus algorithm. Then, the multiple transactions are sorted according to the transaction sequence number.
  • the read-write set and other related information of the sorted transaction are packaged into block B1, that is, the read-write set and other related information in the transaction data received in time period T2 are included in block B1.
  • the duration of the time period T2 can be preset.
  • the reception time at which the client node 101 receives the transaction data of the transaction C1 is located in the time period T2. In other words, relevant information such as the read-write set of transaction C1 is included in block B1.
  • the transaction data of the transaction can be packaged into block B1, that is, the read-write set of the transaction and the block height at the time of endorsement corresponding to the transaction (for example, the block height S h1 of transaction C1, the block height S h2 ) is packaged into block B1 at the same time.
  • the read-write set of the transaction may be packed into block B1, but the maximum block height at the time of endorsement corresponding to the transaction may not be packed into block B1. In this way, the data structure of the current block can be adapted without modifying the data structure of the block.
  • the ordering node 104 can obtain the maximum block height B h of the ordering node 104 when the block B1 is generated.
  • the ordering node can also be used as a ledger node, which stores the blockchain, that is, stores the ledger.
  • the blockchain can be obtained from the ledger node, or in other words, the ledger node can synchronize the blockchain to the ordering node.
  • the ledger node can synchronize the blockchain containing newly uploaded blocks to the ordering node every time a block is uploaded to the chain. In this way, the ordering node can obtain the maximum block height of the ordering node based on its own stored blockchain.
  • the ordering node 104 can, through step 404, combine the read-write set of transactions contained in block B1 and the block height at the time of endorsement corresponding to the transaction contained in block B1 (for example, the block height S h1 of transaction C1, the block height S h2 ) and block height B h are sent to the ledger node 105.
  • block B1 contains the read-write set of the transaction
  • the maximum block height at the time of endorsement corresponding to the transaction if block B1 contains the read-write set of the transaction, the maximum block height at the time of endorsement corresponding to the transaction.
  • the ordering node 104 can specifically send the block B1 and the block height B h to the ledger node 105.
  • step 404 the ordering node 104 can specifically add block B1 and the block height at the time of endorsement corresponding to the transaction contained in block B1 (for example, the block height Sh1 and block height Sh2 of transaction C1), the area The block height B h is sent to the ledger node 105.
  • the ledger node 105 can use the data cached by the ledger node 105 to determine that the transaction is packaged into During the block time, whether the read set of the transaction has been modified, so that the isolation verification of the transaction can be completed efficiently.
  • ledger node 106 can independently conduct isolation verification of transactions by referring to the solution of ledger node 105 for transaction isolation verification. I won’t go into details here.
  • the essence of verifying the legality of transaction C1 is: when the block including transaction C1 is placed, determine whether transaction C1 has been modified by the exchange in the block that has been placed, That is, whether the read set of transaction C1 conflicts with the write set of the transaction in the placed block.
  • the legality verification of transaction C1 requires finding or confirming the placed block that was placed after the endorsement of transaction C1, and using the placed block In the write set, verify the legality of transaction C1.
  • the data processing method provided by the embodiment of this application is to determine whether the transaction C1 is uploaded to the chain within the time period starting from when transaction C1 is pre-executed (i.e. endorsed) by the endorsing node to when block B1 containing transaction C1 is uploaded to the chain. Whether the transaction in the block has modified the read set of transaction C1, that is, it is judged whether the read set of transaction C1 conflicts with the write set of transactions on the chain during this period, so as to realize the isolation verification of transaction C1.
  • on-chain transactions refer to transactions that are included in already-on-chain blocks.
  • the identified or determined placed blocks after the endorsement of transaction C1 specifically refer to: the blocks placed during the period from the time when transaction C1 was endorsed to the time when the block containing transaction C1 was placed. piece.
  • the blockchain is a distributed system and does not have a globally unified timestamp. Therefore, it is difficult to directly use the timestamp to indicate the time period from when transaction C1 is pre-executed by the endorsing node to when block B1 containing transaction C1 is uploaded to the chain.
  • the embodiment of this application uses the block height to represent the moment or timestamp when transaction C1 is pre-executed in the endorsement phase. The block height is used to represent the time period from when transaction C1 is pre-executed by the endorsing node to when block B1 containing transaction C1 is uploaded to the chain.
  • the block height refers to the number of blocks in the blockchain between that block and the genesis block (the first block of the blockchain).
  • the block height can be used as the number of the block on the blockchain to identify the block.
  • you need to query a certain block you can query the block based on its block height.
  • the maximum block height represents the latest block connected to the blockchain, that is, the maximum block height is the block height of the latest block connected to the blockchain.
  • the value of the maximum block height is equal to the number of concatenated blocks on the blockchain.
  • the maximum block height of a blockchain changes as the number of blocks connected to the blockchain increases.
  • the minimum block height represents the first block on the blockchain, the genesis block.
  • the minimum block height is 0, not 1. In other words, the block height starts counting from 0.
  • the block height of a certain block represents the placement time of the block.
  • the placement time of different blocks is different, and the block height is also different. different.
  • a block height can be understood as or represents a specific moment, and the maximum block height of the blockchain represents the current moment.
  • the maximum block height changes accordingly, which is equivalent to the flow of time forward. That is, changes in the maximum block height can represent changes in time. Therefore, the maximum block height of the blockchain system when transaction C1 is endorsed can represent when transaction C1 was endorsed, that is, when the read set of transaction C1 was read.
  • each block height corresponding to multiple placed blocks represents when the corresponding block was placed. If the maximum block height of the blockchain system at the time of transaction C1 endorsement falls within the block height range corresponding to multiple placed blocks, it means that the blocks placed after transaction C1 endorsement are included in the multiple placed blocks. in the drop zone. In this way, the legitimacy of transaction C1 can be obtained by using the write sets of transactions in the multiple placed blocks.
  • Sh can be used to represent the maximum block height when transaction C1 is pre-executed by the endorsed node.
  • Sh can take values at block height Sh1 and block height Sh2 .
  • Sh refers to the minimum value of the maximum block height for all endorsements of transaction C1.
  • Sh is the maximum block height when transaction C1 is pre-executed by the endorsed node
  • B h is the maximum block height when block B1 containing the read-write set of transaction C1 is generated
  • Sh is smaller than B h . If the read set of transaction C1 is modified by the on-chain transaction C2, then the block height of the block where the transaction C2 that modifies the read set of transaction C1 is located is in the interval [S h , B h ].
  • the ledger node 105 can cache n on-chain blocks with a block height range of [B h -n+1, B h ] and the block heights corresponding to n pull-up blocks.
  • n is an integer greater than or equal to 1.
  • n can be a preset value. Developers can freely set the size of n according to the performance of the ledger node.
  • Cached data refers to memory-recorded data, which means the data is still recorded in memory.
  • the transactions in block B1 need to be isolated and verified.
  • the maximum block height B h of the ordering node 104 when block B1 is produced by consensus remains unchanged from the time when block B1 is produced by consensus to the time of isolation verification of block B1.
  • the maximum block height B h is updated.
  • the ledger node 105 has cached n blocks with a height range of [B h -n+1, B h ].
  • the chain block is: the n blocks that have been recently uploaded to the chain relative to the packaging block time of the block to be uploaded.
  • the isolation verification of a transaction includes verifying whether the read set of the transaction conflicts with the write set of the on-chain transaction.
  • Blocks that have been put on the chain can also be called blocks that have been placed on the chain.
  • the ledger node 105 can perform step 602 to determine whether the block height Sh is greater than or equal to B h -n+1. If S h is greater than or equal to B h -n+1, it means that the interval [S h , B h ] is included in the interval [B h -n+1, B h ]. Therefore, if transaction C2 that modifies the read set of transaction C1 exists, the block height of the block where transaction C2 is located is in the interval [B h -n+1, B h ]. The relevant data (such as the write set) of the block whose block height is in the interval [B h -n+1, B h ] is still recorded in the cache of the ledger node 105. In this way, the transaction in the block in the cache can be The write set of transaction C1 is verified to see whether the read set of transaction C1 conflicts with the write set of the on-chain transaction.
  • the value of the key of the read set of transaction C1 can be found in the write set included in the block whose block height is in the interval [S h , B h ].
  • the key of the read set of transaction C1 is found in a block whose block height is in the interval [S h , B h ]
  • the value of the found key is inconsistent with the key value of the read set of transaction C1
  • the key value of the read set of transaction C1 has been modified.
  • the isolation verification of transaction C1 fails, that is, transaction C1 is illegal. In one example, for an illegal transaction, the flag bit can be modified to identify it as illegal.
  • block B1 is generated by packaging the sorted transactions.
  • the read set key of the subsequent transaction is consistent with the write set key of the previous transaction, that is, the subsequent transaction If the account in the read set of the transaction is the same as the account in the write set of the previous transaction, then there is a dependency relationship between the two transactions, and the read set of the subsequent transaction depends on the write set of the previous transaction.
  • the read set of the subsequent transaction depends on the write set of the previous transaction
  • the key of the read set of transaction C1 is not found in the write set included in the block in the interval [S h , B h ]; or, the key is found, and the key value found is The key values of the read set of transaction C1 are consistent. In this case, if the read set of transaction C1 does not depend on the write set of other transactions in block B1, then it can be determined that the isolation verification of transaction C1 passes, that is, transaction C1 is legal. If the read set of transaction C1 depends on the write set of other transactions in block B1, that is, there is a transaction in block B1 that has a dependency relationship with transaction C1, and transaction C1 is a subsequent transaction in the transaction that has a dependency relationship.
  • transaction C2 is determined to be an illegal transaction; when the transaction that transaction C1 relies on is an illegal transaction, transaction C1 can be determined to be a legal transaction.
  • transaction C1 can be determined to be a legal transaction.
  • the subsequent transaction must be illegal; when the previous transaction is illegal, the subsequent transaction is legal as long as it does not conflict with the on-chain transaction.
  • step 601 may be performed to determine the minimum value of the maximum block heights for all endorsements of transaction C1.
  • the minimum value of the maximum block height for all endorsements of transaction C1 is used to determine whether the read set of transaction C1 conflicts with the write set of the on-chain transaction. This can prevent some endorsing nodes from committing evil or committing fraud. The resulting verification results are incorrect. Specifically, as long as at least one endorsement node of transaction C1 does not do evil or falsify, that is, the maximum block height of at least one endorsement node is correct, then the maximum block height of the correct endorsement or the maximum block height of all endorsements The minimum value of the height, or the minimum value of the maximum block height when greater than all endorsements.
  • the interval [maximum block height for correct endorsement, B h ] is contained in or equal to the interval [minimum of the maximum block heights for all endorsements, B h ].
  • S h is greater than or equal to B h -n+1
  • the block height of the block where transaction C2 is located is in the interval [maximum block height for all endorsements] The minimum value of B h ].
  • the selected block height S hx is the fake block height and is greater than the maximum block height when other endorsements are made. Then the determined interval [S hx , B h ] cannot be fully covered after transaction C1 is pre-executed by the endorsement node, and The block was uploaded before the consensus of block B1, which resulted in the omission of the block used to verify transaction C1. When transaction C2 that modifies transaction C1 is included in a missing block, the isolation verification result of transaction C1 will be incorrect.
  • the ledger node 105 can perform step 604 to obtain the key value of the read set of transaction C1 from the state database, and use the key value to verify whether the read set of transaction C1 conflicts with the write set of the on-chain transaction.
  • block B1 may include multiple transactions including transaction C1. Isolation of at least two transactions in the plurality of transactions can be achieved simultaneously. In other words, while verifying the isolation of transaction C1, the isolation of other transactions in block B1 can also be verified. In one example, the isolation of all transactions in block B1 can be verified simultaneously. Among them, the isolation verification schemes of different transactions can be the same or different.
  • the solution shown in Figure 6 can be used to verify the isolation of multiple transactions at the same time, that is, while using the solution shown in Figure 6 to verify transaction C1, the solution shown in Figure 6 can be used to verify the isolation of other transactions. Isolation.
  • block B1 can also include relevant data of transaction C3, that is, it includes transaction C3.
  • the n on-chain blocks in the cache of the ledger node 105 can be used not only to verify whether the read set of transaction C1 conflicts with the write set of the on-chain transaction, but also to verify whether the read set of transaction C3 conflicts with the write set of the on-chain transaction. Write set conflict.
  • n on-chain blocks can also be used to verify the read set of transaction C3. Whether there is a write set conflict in the on-chain transaction.
  • the isolation verification of multiple transactions can be executed concurrently, which can reduce the time occupied by the isolation verification of block B1 and improve the efficiency of isolation verification.
  • Blockchain nodes are usually deployed on service nodes with high computing performance. The isolation verification and concurrent execution of multiple transactions can make full use of the hardware computing resources of the service node, improve the throughput of the service node, and can meet the needs of large-scale and high concurrency. business scenario.
  • the solution shown in Figure 6 can be used to verify the isolation of transaction C1, and at the same time, other isolation verification solutions can be used to verify the isolation of other transactions (such as transaction C3).
  • other isolation verification solutions can be used to verify the isolation of other transactions (such as transaction C3).
  • the key value of the key corresponding to the read set of transaction C1 in the state database can be used to verify the isolation of transaction C1 using the obtained key value.
  • read the key value corresponding to the set of transaction C3 from the state database and use the obtained key value to verify the isolation of transaction C3.
  • the specific method of verifying the isolation of each transaction is not limited.
  • steps 601, 602, 603, and 604 can be collectively referred to as: verifying whether the read set of the transaction to be uploaded is based on the maximum block height at the time of endorsement of the transaction to be uploaded. Conflicts with the write set of the on-chain transaction.
  • the isolation verification of a transaction also includes verifying whether the read set of the transaction depends on the write set of other transactions of the transaction in the block. That is to verify whether the read set of a transaction conflicts with the write set of another transaction in the same block.
  • examples are introduced to verify whether the read set of the transaction to be uploaded conflicts with the write set of the transaction that has been uploaded to the chain, and to verify whether the read set of a transaction conflicts with the write set of another transaction in the same block. process relationship.
  • Block B1 can be set to include relevant data of transaction C1 (read set, etc.), relevant data of transaction C3 (read set, etc.), and relevant data of transaction C4 (read set, etc.).
  • steps 701a, 701b, and 701c can be executed, that is, based on the maximum block height at the time of endorsement of transaction C1, it can be verified whether the read set of transaction C1 is the same as that of the transaction C1.
  • the write set conflict of the on-chain transaction based on the maximum block height when transaction C3 is endorsed, verify whether the read set of transaction C3 conflicts with the write set of the on-chain transaction; based on the maximum block height when transaction C4 is endorsed, verify Whether the read set of transaction C4 conflicts with the write set of the on-chain transaction.
  • steps 701a, 701b, and 701c For the specific execution process of steps 701a, 701b, and 701c, reference can be made to the above introduction to the embodiment shown in FIG. 6 and will not be described again here. For example, as shown in Figure 7A, steps 701a, 701b, and 701c may be executed in parallel.
  • step 702 For transactions whose read set does not conflict with the write set of the on-chain transaction, such as transaction C1, in step 702, it can be verified whether the transaction C1 depends on other transactions in block B1. That is, verify whether the read set of transaction C1 depends on the write set of other transactions in block B1.
  • other transactions refer to transactions in block B1 except transaction C1.
  • the dependence of the transaction read set on other transaction write sets can be referred to the above introduction and will not be repeated here. In this way, it is possible to determine which transactions' read sets depend on the write sets of other transactions in block B1. Among them, you can refer to transaction C1. For each read set in block B1 that does not conflict with the write set of the on-chain transaction, verify whether it depends on other transactions in block B1.
  • the read set of a transaction in block B1 does not conflict with the write set of the on-chain transaction, and the write set of the transaction does not depend on the write set of other transactions in block B1, it can be determined that the transaction passes isolation verification. That means the transaction is legal.
  • the read set of a transaction in block B1 does not conflict with the write set of the on-chain transaction, but the read set of the transaction depends on the write set of other transactions, and if the transaction the transaction relies on is legal, the transaction is determined illegal.
  • block B1 After each transaction in block B1 has been isolated and verified, block B1 can be connected to the blockchain, that is, block B1 is uploaded to the chain. When block B1 is uploaded to the chain, the write set of legal transactions in block B1 is updated to the state database of the ledger node 105, that is, the key value of the corresponding key is updated. The write set of illegal transactions is not updated to the state database of the ledger node 105.
  • the client node 101 can perform step 401 and send an endorsement service request to the endorsement node 102 and the endorsement node 103.
  • an endorsement service request to the endorsement node 102 and the endorsement node 103.
  • the endorsing node 102 may send the signature 21, the read-write set 22, and the block height S h1 to the client node 101 through 402a.
  • the endorsing node 103 can send the signature 31, the read-write set 32 and the block height Sh2 to the client node 101 through 402b.
  • the client node 101 can receive endorsement results for transaction C1 sent by multiple endorsement nodes, and thus can receive multiple endorsement results for transaction C1, where multiple endorsement results correspond to multiple endorsement nodes one-to-one.
  • the client node 101 can construct transaction information based on the multiple endorsement results. For details, reference may be made to the above introduction to the embodiment shown in FIG. 4 , which will not be described again here.
  • the client node 101 can send the constructed transaction data of transaction C1 to the ordering node 104 through step 403.
  • the ordering node 104 can generate block B1, or consensus block, based on the transaction data of multiple transactions received in time period T2.
  • the ordering node 104 can package the read-write sets and other related information of multiple transactions received in the time period T2 into block B1, that is, generate block B1.
  • the ordering node 104 can obtain the maximum block height B h of the ordering node 104 when the block B1 is generated.
  • the ordering node 104 can, through step 404, combine the read-write set of transactions contained in block B1 and the block height at the time of endorsement corresponding to the transaction contained in block B1 (for example, the block height S h1 of transaction C1, the block height S h2 ) and block height B h are sent to the ledger node 105.
  • the block height S h1 of transaction C1, the block height S h2 for example, the block height S h1 of transaction C1, the block height S h2
  • block height B h for example, the block height S h1 of transaction C1, the block height S h2
  • the ledger node 105 can use the data cached by the ledger node 105 to determine that the transaction is packaged into During the block time, whether the read set of the transaction has been modified, so that the isolation verification of the transaction can be completed efficiently. Specifically, the ledger node 105 can verify whether the read set of transaction C1 conflicts with the write set of the on-chain transaction in step 701a. In step 701b, verify whether the read set of transaction C3 conflicts with the write set of the on-chain transaction. In step 701c, verify whether the read set of transaction C4 conflicts with the write set of the on-chain transaction.
  • step 701a verify whether the read set of transaction C3 conflicts with the write set of the on-chain transaction.
  • step 701c verify whether the read set of transaction C4 conflicts with the write set of the on-chain transaction.
  • step 702 the ledger node 105 can perform step 702 to verify whether a transaction in block B1 depends on other transactions in block B1.
  • step 702 is executed, that is, to verify whether they depend on other transactions in block B1.
  • block B1 can be connected to the blockchain, that is, block B1 is put on the chain.
  • the write set of legal transactions in block B1 is updated to the state database of the ledger node 105, that is, the key value of the corresponding key is updated.
  • the write set of illegal transactions is not updated to the state database of the ledger node 105.
  • the data processing method provided by this embodiment only requires some memory overhead and computing resources, and can quickly complete the isolation verification of transactions in the block to be uploaded, greatly reducing the time taken by the isolation verification, and speeding up the block uploading process.
  • the speed of the chain improves the performance of the blockchain system.
  • the data processing method provided by this embodiment is less affected by the data scale in the state database, so that the speed of isolation verification will not change with the increase in the data scale in the state database, ensuring the long-term stability of the blockchain system. Operational performance stability.
  • the data processing method provided in this embodiment uses the data cached in the memory to perform isolation verification of transactions in the block to be uploaded to the chain, avoiding the occupation of memory by isolation verification and reducing the impact on the state database, and, It speeds up the speed of blockchain uploading, which helps the high-performance operation of the blockchain system in complex business scenarios.
  • the data processing method provided by this embodiment can verify the isolation of multiple transactions in parallel, greatly reducing the time required to verify the isolation of transactions in the block to be uploaded, so that the block to be uploaded can be uploaded to the chain as soon as possible. The performance of the blockchain system is further improved.
  • step 801 can be performed first to verify whether each transaction depends on other transactions in block B1.
  • transaction C1 as an example, you can verify whether transaction C1 depends on other transactions in block B1. That is, verify whether the read set of transaction C1 depends on the write set of other transactions in block B1.
  • other transactions refer to transactions in block B1 except transaction C1.
  • the dependence of the transaction read set on other transaction write sets can be referred to the above introduction and will not be repeated here. In this way, it is possible to determine which transactions' read sets depend on the write sets of other transactions in block B1. Among them, you can refer to transaction C1 to verify whether each transaction in block B1 depends on other transactions in block B1.
  • transaction E1 depends on another transaction E2, which means that the read set of transaction E1 depends on the write set of transaction E2. That is, in the sorted transaction sequence, transaction E1 is the subsequent transaction of transaction E2, or transaction E2 is the preceding transaction of transaction E1.
  • the key value of the read set of transaction E1 is consistent with the key value of the write set of transaction E2.
  • step 802a based on the maximum block height at the time of endorsement of transaction C1, verify whether the read set of transaction C1 conflicts with the write set of the on-chain transaction
  • step 802b based on the endorsement time of transaction C3
  • the maximum block height verify whether the read set of transaction C3 conflicts with the write set of the on-chain transaction.
  • the read set of a transaction in block B1 does not conflict with the write set of the on-chain transaction, and the write set of the transaction does not depend on the write set of other transactions in block B1, it can be determined that the transaction passes isolation verification. That means the transaction is legal.
  • the transaction does not pass the isolation verification, that is, the transaction is illegal. It can be determined whether the illegal transaction is relied on by other exchanges. If the illegal transaction is relied on by other exchanges, you can continue to verify the transaction that relies on the illegal transaction. For example, as shown in Figure 8A, transaction C4 depends on transaction C3, and transaction C3 is determined to be an illegal transaction, then step 803 can be continued to verify whether the read set of transaction C1 is based on the maximum block height at the time of endorsement of transaction C4. Conflicts with the write set of the on-chain transaction. If there is a conflict, transaction C4 is illegal. If there is no conflict, transaction C4 is legal.
  • block B1 After each transaction in block B1 has been isolated and verified, block B1 can be connected to the blockchain, that is, block B1 is uploaded to the chain. When block B1 is uploaded to the chain, the write set of legal transactions in block B1 is updated to the state database of the ledger node 105, that is, the key value of the corresponding key is updated. The write set of illegal transactions is not updated to the state database of the ledger node 105.
  • the client node 101 can perform step 401 and send an endorsement service request to the endorsement node 102 and the endorsement node 103.
  • an endorsement service request to the endorsement node 102 and the endorsement node 103.
  • the endorsing node 102 may send the signature 21, the read-write set 22, and the block height S h1 to the client node 101 through 402a.
  • the endorsing node 103 can send the signature 31, the read-write set 32 and the block height Sh2 to the client node 101 through 402b.
  • the client node 101 can receive endorsement results for transaction C1 sent by multiple endorsement nodes, and thus can receive multiple endorsement results for transaction C1, where multiple endorsement results correspond to multiple endorsement nodes one-to-one.
  • the client node 101 can construct transaction information based on the multiple endorsement results. For details, reference may be made to the above introduction to the embodiment shown in FIG. 4 , which will not be described again here.
  • the client node 101 can send the constructed transaction data of transaction C1 to the ordering node 104 through step 403.
  • the ordering node 104 can generate block B1, or consensus block, based on the transaction data of multiple transactions received in time period T2. Among them, the ordering node 104 can package the read-write sets and other information of multiple transactions received in the time period T2 into block B1 to generate block B1.
  • block B1 or consensus block
  • the ordering node 104 can obtain the maximum block height B h of the ordering node 104 when the block B1 is generated.
  • the ordering node 104 can, through step 404, combine the read-write set of transactions contained in block B1 and the block height at the time of endorsement corresponding to the transaction contained in block B1 (for example, the block height S h1 of transaction C1, the block height S h2 ) and block height B h are sent to the ledger node 105.
  • the block height S h1 of transaction C1, the block height S h2 for example, the block height S h1 of transaction C1, the block height S h2
  • block height B h for example, the block height S h1 of transaction C1, the block height S h2
  • the ledger node 105 can use the data cached by the ledger node 105 to determine that the transaction is packaged into During the block time, whether the read set of the transaction has been modified, so that the isolation verification of the transaction can be completed efficiently. Specifically, as shown in Figure 8B, the ledger node 105 can perform step 801 to verify whether a transaction in block B1 depends on other transactions in block B1. Please refer to the above introduction for details and will not go into details here. Among them, execution step 801 is performed for each transaction in block B1, that is, it is verified whether the transaction depends on other transactions in block B1.
  • step 802a and step 802b may be executed in parallel.
  • block B1 can be connected to the blockchain, that is, block B1 is put on the chain.
  • the write set of legal transactions in block B1 is updated to the state database of the ledger node 105, that is, the key value of the corresponding key is updated.
  • the write set of illegal transactions is not updated to the state database of the ledger node 105.
  • the data processing method provided by this embodiment only requires some memory overhead and computing resources, and can quickly complete the isolation verification of transactions in the block to be uploaded, greatly reducing the time taken by the isolation verification, and speeding up the block uploading process.
  • the speed of the chain improves the performance of the blockchain system.
  • the data processing method provided by this embodiment is less affected by the data scale in the state database, so that the speed of isolation verification will not change with the increase in the data scale in the state database, ensuring the long-term stability of the blockchain system. Operational performance stability.
  • the data processing method provided in this embodiment uses the data cached in the memory to perform isolation verification of transactions in the block to be uploaded to the chain, avoiding the occupation of memory by isolation verification and reducing the impact on the state database, and, It speeds up the speed of blockchain uploading, which helps the high-performance operation of the blockchain system in complex business scenarios.
  • the data processing method provided by this embodiment can verify the isolation of multiple transactions in parallel, greatly reducing the time required to verify the isolation of transactions in the block to be uploaded, so that the block to be uploaded can be uploaded to the chain as soon as possible. The performance of the blockchain system is further improved.
  • step 901 can be performed first to verify whether a transaction depends on other transactions in block B1.
  • transaction C1 as an example, you can verify whether transaction C1 depends on other transactions in block B1. That is, verify whether the read set of transaction C1 depends on the write set of other transactions in block B1.
  • other transactions refer to transactions in block B1 except transaction C1.
  • the dependence of the transaction read set on other transaction write sets can be referred to the above introduction and will not be repeated here.
  • step 801 is executed for each transaction in block B1, that is, it is verified whether the transaction depends on other transactions in block B1. In this way, it can be determined that the read set of transaction C1 depends on the write set of other transactions in block B1.
  • step 902 can be performed to verify whether the read set of transaction C1 conflicts with the write set of the on-chain transaction based on the maximum block height at the time of endorsement of transaction C1.
  • step 902 can be performed to verify whether the read set of transaction C1 conflicts with the write set of the on-chain transaction based on the maximum block height at the time of endorsement of transaction C1.
  • transaction C1 depends on other transactions in block B1, such as transaction C3, the legitimacy of transaction C3 can be verified first. If transaction C3 is legal, then transaction C1 is determined to be an illegal transaction. If transaction C3 is illegal, step 902 is executed. If the read set of transaction C1 does not conflict with the write set of the on-chain transaction, transaction C1 is legal. Otherwise, transaction C1 is illegal.
  • block B1 can be connected to the blockchain, that is, block B1 is put on the chain.
  • the write set of legal transactions in block B1 is updated to the state database of the ledger node 105, that is, the key value of the corresponding key is updated.
  • the write set of illegal transactions is not updated to the state database of the ledger node 105.
  • the data processing method provided by this embodiment only requires some memory overhead and computing resources, and can quickly complete the isolation verification of transactions in the block to be uploaded, greatly reducing the time taken by the isolation verification, and speeding up the block uploading process.
  • the speed of the chain improves the performance of the blockchain system.
  • the data processing method provided by this embodiment is less affected by the data scale in the state database, so that the speed of isolation verification will not change with the increase in the data scale in the state database, ensuring the long-term stability of the blockchain system. Operational performance stability.
  • the data processing method provided in this embodiment uses the data cached in the memory to perform isolation verification of transactions in the block to be uploaded to the chain, avoiding the occupation of memory by isolation verification and reducing the impact on the state database, and, It speeds up the speed of blockchain uploading, which helps the high-performance operation of the blockchain system in complex business scenarios.
  • the embodiment of the present application provides a data processing method that can be applied to the first node in the blockchain system.
  • This method is another expression of the scheme described above, and the two are combined.
  • the first node may be a ledger node in the blockchain system.
  • the method includes the following steps.
  • Step 1001 Obtain the read set of the first transaction and obtain the first block height.
  • the first block height is the maximum block height in the blockchain system when the first transaction is endorsed.
  • the cache of the first node stores the write sets included in the plurality of placed blocks in the blockchain system, and the block heights corresponding to the plurality of placed blocks;
  • Step 1003 When the first block height is within the range of block heights corresponding to the multiple placed blocks, based on the read set of the first transaction, the block height is compared with the multiple placed blocks. The write set included in the block obtains the legitimacy of the first transaction.
  • the block height corresponding to the multiple placed blocks belongs to the interval [B h -n+1, B h ], then when the first block height is greater than or equal to B h -n +1, the first block height is within the range of block heights corresponding to the multiple placed blocks, where n is an integer greater than or equal to 1, and B h is an integer greater than or equal to 0.
  • B h is the maximum block height in the blockchain system when the block to which the first transaction belongs is generated.
  • the method further includes: when the first block height is not within the range of block heights corresponding to the plurality of placed blocks, then from the state database of the first node , obtain the first key value of the key corresponding to the read set of the first transaction; obtain the legality of the first transaction based on the read set of the first transaction and the first key value.
  • the blockchain system further includes a first endorsement node and a second endorsement node for endorsing the first transaction
  • obtaining the first block height includes: obtaining the second block height height and the third block height, where the second block height is the maximum block height in the blockchain system when the first transaction is endorsed by the first endorsement node; the third block height Block height is the maximum block height in the block system when the first transaction is endorsed by the second endorsement node; the smaller of the second block height and the third block height is used as The height of the first block.
  • the method further includes: obtaining a read set of a second transaction, where the first transaction and the second transaction belong to the same block; in the read set based on the first transaction, and the read set of the second transaction.
  • a read set based on the second transaction is executed in parallel to obtain the legality of the second transaction.
  • obtaining the legality of the first transaction based on the read set of the first transaction and the write set included in the plurality of placed blocks includes: If the read set of a transaction conflicts with the write set of a third transaction, the first transaction is illegal and the third transaction is included in the multiple placed blocks.
  • obtaining the legality of the first transaction based on the read set of the first transaction and the write set included in the plurality of placed blocks includes: When the read set of the transaction does not conflict with the write sets included in the multiple placed blocks, the legality of the first transaction is obtained based on the read set of the first transaction and the write sets of other transactions. property, wherein the other transactions are transactions other than the first transaction in the block to which the first transaction belongs.
  • obtaining the legality of the first transaction based on the read set of the first transaction and the write set of other transactions includes: when the first transaction does not depend on the write set of other transactions In the case of Legal; or, if the first transaction depends on the write set of the fourth transaction among the other transactions, and the fourth transaction is legal, the first transaction is illegal.
  • the method provided by the embodiment of this application only requires some memory overhead and computing resources, can quickly complete the isolation verification of transactions in the block to be uploaded, and greatly reduces the time required to verify the isolation of transactions in the block to be uploaded. It speeds up the speed of blockchain uploading and improves the performance of the blockchain system. Moreover, this solution is less affected by the data size in the state database when performing isolation verification on transactions, so that the speed of isolation verification will not change with the increase in the data size in the state database, ensuring that the blockchain The performance stability of the system for long-term operation. In addition, this solution uses the data cached in the memory to perform isolation verification of transactions in the blocks to be uploaded to the chain, avoiding the occupation of memory by transaction isolation verification, reducing the impact on the state database, and speeding up the block upload. The speed of the chain helps the blockchain system run with high performance in complex business scenarios.
  • the embodiment of the present application provides a data processing method that can be applied to the first node in the blockchain system.
  • the first node may be a ledger node in the blockchain system.
  • the method includes the following steps.
  • Step 1101 Obtain the read set of the first transaction and the read set of the second transaction.
  • the first transaction and the second transaction belong to the same block;
  • Step 1103 In the process of obtaining the legality of the first transaction based on the read set of the first transaction, execute the read set based on the second transaction in parallel to obtain the legality of the second transaction.
  • the cache of the first node stores write sets included in a plurality of committed blocks in the blockchain system, and blocks corresponding to the plurality of committed blocks. height; the method further includes: obtaining a first block height, which is the largest block height in the blockchain system when endorsing the first transaction; Obtaining the legality of the first transaction includes: based on the read set of the first transaction and the write sets included in the plurality of placed blocks, obtaining the first transaction Legality of transaction.
  • the method further includes: obtaining a second block height, where the second block height is the maximum block height in the blockchain system when endorsing the second transaction;
  • Obtaining the legality of the second transaction based on the read set of the second transaction includes: based on the read set of the second transaction and the write set included in the multiple placed blocks, obtaining The legality of the second transaction.
  • obtaining the legality of the second transaction based on the read set of the second transaction includes: obtaining the read set corresponding to the second transaction from the state database of the first node. The first key value of the key; based on the read set of the second transaction and the first key value, the legality of the second transaction is obtained.
  • obtaining the legality of the first transaction based on the read set of the first transaction includes: obtaining the read set corresponding to the first transaction from the state database of the first node. The second key value of the key; based on the read set of the first transaction and the second key value, the legality of the first transaction is obtained.
  • the data processing method provided by the embodiment of this application can simultaneously verify the isolation of multiple transactions in the same block, enable the block to be placed on the market as soon as possible, and improve the performance of the blockchain system.
  • An embodiment of the present application provides a data processing device.
  • the device includes functional units for implementing the method shown in Figure 10.
  • the device may include the following functional units.
  • the acquisition unit 1210 is used to obtain the read set of the first transaction and obtain the first block height.
  • the first block height is the largest area in the blockchain system when the first transaction is endorsed.
  • Block height the cache of the first node stores the write sets included in the multiple posted blocks in the blockchain system, and the block heights corresponding to the multiple posted blocks;
  • Obtaining unit 1220 is configured to, when the first block height is within the range of block heights corresponding to the multiple placed blocks, based on the read set of the first transaction, and the multiple The write set included in the placed block obtains the legitimacy of the first transaction.
  • An embodiment of the present application provides a data processing device.
  • the device includes functional units for implementing the method shown in Figure 11. Continuing to refer to Figure 12, the device may include the following functional units.
  • the acquisition unit 1210 is used to obtain the read set of the first transaction and obtain the first block height.
  • the first block height is the largest area in the blockchain system when the first transaction is endorsed.
  • Block height the cache of the first node stores the write sets included in the multiple posted blocks in the blockchain system, and the block heights corresponding to the multiple posted blocks;
  • Obtaining unit 1220 is configured to, when the first block height is within the range of block heights corresponding to the multiple placed blocks, based on the read set of the first transaction, and the multiple The write set included in the placed block obtains the legitimacy of the first transaction.
  • each terminal includes a corresponding hardware structure and/or software module to perform each function.
  • the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is performed by hardware or computer software driving the hardware depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each specific application, but such implementations should not be considered beyond the scope of this application.
  • an embodiment of the present application provides a blockchain node 1300.
  • the blockchain node 1300 can perform the operations performed by the ledger node or the first node in the embodiments shown in Figures 4 to 11. For example, it can perform the operations of the first node in the embodiment shown in Figure 10. For another example, it can Execute the operation of the first node in the embodiment shown in Figure 11.
  • the blockchain node 1300 may include a processor 1310 and a memory 1320. Memory 1320 stores instructions that can be executed by processor 1310 . When the instruction is executed by the processor 1310, the blockchain node 1300 can perform the operations performed by the ledger node or the first node in the above method embodiments. For example, it can perform the first operation in the embodiment shown in Figure 10 or Figure 11. Node operations.
  • processors in the embodiments of the present application can be a central processing unit (CPU), or other general-purpose processor, digital signal processor (DSP), or application-specific integrated circuit (application specific integrated circuit, ASIC), field programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof.
  • a general-purpose processor can be a microprocessor or any conventional processor.
  • the method steps in the embodiments of the present application can be implemented by hardware or by a processor executing software instructions.
  • Software instructions can be composed of corresponding software modules, and software modules can be stored in random access memory (random access memory, RAM), flash memory, read-only memory (read-only memory, ROM), programmable read-only memory (programmable rom) , PROM), erasable programmable read-only memory (erasable PROM, EPROM), electrically erasable programmable read-only memory (electrically EPROM, EEPROM), register, hard disk, mobile hard disk, CD-ROM or other well-known in the art any other form of storage media.
  • An exemplary storage medium is coupled to the processor such that the processor can read information from the storage medium and write information to the storage medium.
  • the storage medium can also be an integral part of the processor.
  • the processor and storage media may be located in an ASIC.
  • the above embodiments it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
  • software it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.
  • the computer instructions may be stored in or transmitted over a computer-readable storage medium.
  • the computer instructions may be transmitted from one website, computer, server or data center to another website through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means. , computer, server or data center for transmission.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains one or more available media integrated.
  • the available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, solid state disk (SSD)), etc.

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请涉及数据处理方法、区块链节点及区块链系统。该方法包括:获取第一交易的读集,以及获取第一区块高度,第一区块高度为对第一交易进行背书时,区块链系统中最大的区块高度,第一节点的缓存中存储有区块链系统中多个已落盘区块所包括的写集,以及多个已落盘区块对应的区块高度;当第一区块高度在多个已落盘区块对应的区块高度的范围内时,则基于第一交易的读集,与多个已落盘区块所包括的写集,得到第一交易的合法性。

Description

一种数据处理方法、区块链节点及区块链系统 技术领域
本申请涉及数据处理技术领域,具体涉及一种数据处理方法、区块链节点及区块链系统。
背景技术
区块链(block chain)是一种将数据区块以顺序相连的方式组合成的、呈链式数据结构的分布式账本。区块链具有去中心化、不可篡改、可追溯等优势,在多个领域具有广泛的应用前景。
预执行(execute-order-validation,EOV)架构的区块链,具备读写分离的交易流程,可以能够提供更好的系统性能,已得到的广泛应用。在EOV架构的区块链中,交易数据提交上链之前,需要先完成隔离性(isolation)验证。因此,能否高效地完成隔离性验证,对区块链系统性能具有显著影响。
发明内容
本申请实施例提供了一种数据处理方法、区块链节点及区块链系统,可以提高区块链系统的性能。
第一方面,提供了一种数据处理方法,应用于区块链系统中的第一节点,该方法包括:获取第一交易的读集,以及获取第一区块高度,第一区块高度为对第一交易进行背书时,区块链系统中最大的区块高度,第一节点的缓存中存储有区块链系统中多个已落盘区块所包括的写集,以及多个已落盘区块对应的区块高度;当第一区块高度在多个已落盘区块对应的区块高度的范围内时,则基于第一交易的读集,与多个已落盘区块所包括的写集,得到第一交易的合法性。
其中,交易的读集是指背书节点在模拟执行或者说预执行该交易(即该交易背书)时,读取到的键(key)以及键值(value)。其中,写集是指交易被模拟执行或者说预执行后,所生成的数据,其中,包括键以及键值。在一个例子中,键具体可以指示账户,对应的键值指示账户余额。那么读集中的键值是指交易被模拟执行或者说预执行之前的账户余额,写集中的键值是指交易被模拟执行或者说预执行之后的账户余额。
其中,在本申请实施例中,对第一交易进行合法性验证的实质是:在包括第一交易的区块落盘时,判断第一交易是否被已落盘区块中的交易所修改,即第一交易的读集是否和已落盘区块中的交易的写集冲突。其中,不难理解,有可能修改第一交易的读集的交易的落盘时间是在第一交易背书之后。因此,在包括第一交易的区块落盘时,对第一交易进行的合法性验证,需要找出或者说确定在第一交易背书后落盘的已落盘区块,并利用该已落盘区块中的写集,验证第一交易的合法性。另外,由于是在包括第一交易的区块落盘时,且还未完成落盘的情况下,找出或者说确定在第一交易背书后落盘的已落盘区块。因此,找出或确定的第一交易背书后的落盘的已落盘区块具体是指:在从第一交易背书时到包含第一交易的区块落盘时的这一时间段内落盘的区块。
由于,区块链系统是一种分布式系统,没有全局同一的时间戳。并且,第一交易的背书、产生包括第一交易的区块、验证第一交易的合法性可能是由不同的区块完成的。因此,难以直接使用时间戳来表示从第一交易背书时到包含第一交易的区块落盘时的这一时间段。为此,本申请实施例采用了区块高度来代表时间戳,以及采用区块高度区间来代表时间段。
其中,对于区块链上的一个区块而言,区块高度(block height)是指该区块链中该区块和创世区块(该区块链的第一个区块)之间的块数。区块高度可以用作区块链上区块的编号,用于标识该区块。可以根据区块的区块高度,查询该区块。其中,最大的区块高度代表了最晚串接到或者说落盘到区块链上的区块,即最大的区块高度是指最晚串接到区块链上的区块的区块高度。最大的区块高度的值等于区块链上串接的区块的个数。区块链的最大的区块高度随着串接到区块链上的区块个数的增加而变化。最小的区块高度代表区块链上的第一个区块,即创世区块。另外,需要指出的是,通常而言,在区块链系统中,最小的区块高度是0,而非1。换言之,区块高度是从0开始计数的。
另外,需要说明的是,本申请实施例所描述的区块链系统可以维护或者说记录一条区块链,也可以维护或者说记录多条区块链。在本申请实施例中,如无特殊说明,所提到的区块高度是同一条区块链上的区块高度。举例而言,区块链系统记录了区块链G1这一条区块链,那么第一区块高度是指对第一交易进行背书时区块链G1的最大的区块高度,多个已落盘区块是指已串接到或者说落盘到区块链G1的区块,相应地,多个已落盘区块的区块高度是区块链G1的区块高度。
结合以上描述,不难理解,对于同一条区块链而言,其中的某个区块的区块高度代表了该区块的落盘时间,不同区块的落盘时间不同,区块高度也不同。也就是说,对于同一条区块链而言,一个区块高度可以理解为或者代表了一个特定时刻,该区块链的最大区块高度代表了当前时刻。每当一个区块落盘,则最大区块高度随之变化,相当于时间向前流动。即最大区块高度的变化可以代表时间的变化。因此,第一交易被预执行(即第一交易背书)时的最大区块高度,可以代表第一交易是在何时被背书的,即代表第一交易的读集是何时被读取到的。
另外,多个已落盘区块对应的区块高度中的每个区块高度代表了相应的区块是何时落盘。若第一交易背书时的区块链系统的最大区块高度落入到了多个已落盘区块对应的区块高度范围,说明在第一交易背书后落盘的区块包括在了该多个已落盘区块中。如此,可以利用该多个已落盘区块中交易的写集,得到第一交易的合法性。
本申请实施例提供的数据处理方法,通过判断第一交易背书时的最大区块高度,是否落入到多个已落盘区块对应的区块高度范围内,可以得到在第一交易背书后落盘的区块是否包括进了该多个已落盘区块中,即是否包括进了缓存的数据中。若包括到了缓存的数据中,则可以利用缓存中的数据,完成第一交易的合法性验证。由此,通过本申请实施例提供的方法,第一节点可以利用缓存中数据,完成第一交易的合法性验证,而无需从状态数据库获取数据,可以降低第一交易合法性验证所需时长,降低第一区块上链的时延,提高区块链系统的性能。
并且,第一节点通过本申请实施例提供的方法对第一交易进行合法性验证,使得合法性验证受第一节点的状态数据库中的数据规模影响较小,合法验证的速度不会随着状态数据库中数据规模的增大而变化,保证了区块链系统长久运行地性能稳定性。
以及,在本申请实施例提供的方法中,第一节点是利用缓存中的数据对第一交易进行合法性验证的,避免或者减少了合法性验证对存储器的占用,降低了对状态数据库的影响。
另外,通过本申请实施例提供的方法对第一交易进行合法性验证,可以降低处理器和存储器之间的通信开销,节省硬件资源。
在一种可能的实施方式中,多个已落盘区块对应的区块高度属于区间[B h-n+1,B h],则当第一区块高度大于或等于B h-n+1时,第一区块高度在多个已落盘区块对应的区块高度的范围内,其中n大于或等于1的整数,B h为大于或等于0的整数。
在该实施方式中,多个已落盘区块可以为区块高度分布为B h-n+1、B h-n+2、……,B h的n个已落盘区块,可以通过对第一区块高度(即对第一交易进行背书时区块链系统中最大的区块高度)和多个已落盘区块中区块高度最小的区块的区块高度进行比较,可以得到可能修改第一交易的读集的交易包含在该多个已落盘区块中,从而可以利用多个已落盘区块所包括的写集,对第一交易进行合法性验证,保障了第一交易的合法性验证的完备性。
在一种可能的实施方式中,B h为第一交易所属的区块产生时,区块链系统中最大的区块高度。
在该实施方式中,多个已落盘区块包括了第一交易所属的区块产生时,区块链系统中最大的区块高度,避免了可能修改第一交易的读集的交易的遗漏,保障了第一交易合法性验证的完备性。
在一种可能的实施方式中,该方法还包括:当第一区块高度不在多个已落盘区块对应的区块高度的范围内时,则从第一节点的状态数据库中,获取第一交易的读集对应的键的第一键值;基于第一交易的读集,与第一键值,得到第一交易的合法性。
其中,如上所述,读集包括键以及键值。此处的读集对应的键是指读集中的键。
在该实施方式中,若第一区块高度不在多个已落盘区块对应的区块高度的范围内时,说明,有可能修改第一交易读集的交易可能不包括在多个已落盘区块中。这种情况下,从状态数据库中获取第一交易的读集对应的键的键值,并利用该键值,对第一交易进行合法性验证。
通常而言,键在状态数据库中的键值为该键的最新键值。具体而言,每落盘一个区块,区块链节点(具体而言是账本节点)会根据该落盘区块中合法交易的写集更新状态数据库中相应键的键值。因此,从状态数据库中获取的某个键的键值通常是该键的最新键值。因此,从状态数据库中获取第一交易的读集对应键的键值,并据此,对第一交易进行合法性验证,可以保障第一交易合法性验证的完备性。
在一种可能的实施方式中,区块链系统还包括用于对第一交易进行背书的第一背书节点和第二背书节点,获取第一区块高度包括:获取第二区块高度和第三区块高度,其中,第二区块高度为第一交易被第一背书节点背书时,区块链系统中最大的区块高度;第三区块高度第一交易被第二背书节点背书时,区块系统中最大的区块高度;将第二区块高度和第三区块高度中小的那个作为第一区块高度。
在该实施方式中,当有多个背书节点对第一交易进行背书时,即存在第一交易具有多个背书时的最大区块高度时,利用多个背书时的最大区块高度中的较小的那个或者最小的那个来确定用于验证第一交易合法性的区块,可以避免或减少部分背书节点造假所导致的验证结果出错风险。
在一种可能的实施方式中,该方法还包括:获取第二交易的读集,第一交易和第二交易属于同一区块;在基于第一交易的读集,与多个已落盘区块所包括的写集,得到第一交易的合法性的过程中,并行执行基于第二交易的读集得到第二交易的合法性。其中,第二交易可以为第一交易所属区块中的除第一交易之外的全部其他交易或者部分其他交易。
在该实施方式中,第一节点在利用缓存的数据,验证第一交易的合法性的同时,还可以验证其他交易的合法性。也就是说,多个交易的合法性验证可以并发执行,从而进一步减少了完成整个区块中交易合法性验证所需的时长,进一步降低了区块上链的时延,提高了区块链系统的性能。其中,可以并发执行第一交易所属区块中的全部交易的合法性验证,从而极 大降低了区块上链的时延,提高了区块链系统的性能。也可以并发执行第一交易所属区块中的部分交易的合法性验证。
在一种可能的实施方式中,基于所述第一交易的读集,与多个已落盘区块所包括的写集,得到第一交易的合法性包括:在第一交易的读集与第三交易的写集冲突的情况下,第一交易不合法,第三交易包括在多个已落盘区块中。
若第一交易的读集与第三交易的写集冲突,即第一交易的读集与已落盘区块中交易的写集冲突,则认定第一交易不合法,从而保障区块链系统中的数据的一致性。
在一种可能的实施方式中,基于第一交易的读集,与多个已落盘区块所包括的写集,得到第一交易的合法性包括:在第一交易的读集与多个已落盘区块所包括的写集均不冲突的情况下,基于第一交易的读集和其他交易的写集,得到第一交易的合法性,其中,其他交易为第一交易所属区块中除第一交易之外的交易。
在该实施方式中,在验证第一交易的读集不和已落盘区块中的交易的写集冲突之后,可以进一步验证第一交易的读集是否和同区块中其他交易的写集冲突,即第一交易的读集是否依赖其他交易的写集,以避免同一区块中出现读集和其他合法交易写集冲突的合法交易。
在一种可能的实施方式中,基于第一交易的读集和其他交易的写集,得到第一交易的合法性包括:在第一交易不依赖其他交易的写集的情况下,第一交易合法;或者,在第一交易依赖其他交易中的第四交易的写集,且第四交易不合法的情况下,第一交易合法;或者,在第一交易依赖其他交易中的第四交易的写集,且第四交易合法的情况下,第一交易不合法。
在该实施方式中,在第一交易的读集不依赖同一区块中的其他交易,或者依赖的交易不合法的情况下,可以认定第一交易合法。在第一交易的读集依赖同一区块中的其他交易,其所依赖的交易合法的情况下,可以认定第一交易不合法,从而保障区块链系统中的数据的一致性。
第二方面,提供了一种数据处理方法,应用于区块链系统中的第一节点,该方法包括:获取第一交易的读集和第二交易的读集,第一交易和第二交易属于同一区块;在基于第一交易的读集得到第一交易的合法性的过程中,并行执行基于第二交易的读集得到第二交易的合法性。其中,第一交易和/或第二交易可以包括至少一个交易。在一个例子中,第一交易和第二交易构成了同一区块中的全部交易。在一个例子中,第一交易和第二交易可以为同一区块中的部分交易。
利用该方法,可以同时验证同一区块中多个交易的合法性,从而进一步减少了完成整个区块中交易合法性验证所需的时长,进一步降低了区块上链的时延,提高了区块链系统的性能。其中,可以并发执行第一交易所属区块中的全部交易的合法性验证,从而极大降低了区块上链的时延,提高了区块链系统的性能。也可以并发执行第一交易所属区块中的部分交易的合法性验证。
在一种可能的实施方式中,第一节点的缓存中存储有区块链系统中多个已落盘区块所包括的写集,以及多个已落盘区块对应的区块高度;方法还包括:获取第一区块高度,第一区块高度为对第一交易进行背书时,区块链系统中最大的区块高度;基于第一交易的读集得到第一交易的合法性包括:基于第一交易的读集,与多个已落盘区块所包括的写集,得到第一交易的合法性。
在该实施方式中,第一节点在利用缓存的数据,验证第一交易的合法性的同时,还可以验证其他交易的合法性。也就是说,多个交易的合法性验证可以并发执行,从而进一步减少 了完成整个区块中交易合法性验证所需的时长,进一步降低了区块上链的时延,提高了区块链系统的性能。
在一种可能的实施方式中,该方法还包括:获取第二区块高度,第二区块高度为对第二交易进行背书时,区块链系统中最大的区块高度;基于第二交易的读集得到第二交易的合法性包括:基于第二交易的读集,与多个已落盘区块所包括的写集,得到第二交易的合法性。
在该实施方式中,第一节点在利用缓存的数据,验证第一交易的合法性的同时,还可以利用缓存的数据,验证其他交易的合法性。也就是说,多个交易的合法性验证可以并发执行,从而进一步减少了完成整个区块中交易合法性验证所需的时长,进一步降低了区块上链的时延,提高了区块链系统的性能。
在一种可能的实施方式中,基于第二交易的读集得到第二交易的合法性包括:从第一节点的状态数据库中,获取第二交易的读集对应的键的第一键值;基于第二交易的读集,与第一键值,得到第二交易的合法性。
在该实施方式中,第一节点在利用缓存的数据,验证第一交易的合法性的同时,还可以利用从状态数据库获取数据,来验证其他交易的合法性。也就是说,多个交易的合法性验证可以并发执行,从而进一步减少了完成整个区块中交易合法性验证所需的时长,进一步降低了区块上链的时延,提高了区块链系统的性能。
在一种可能的实施方式中,基于第一交易的读集得到第一交易的合法性包括:从第一节点的状态数据库中,获取第一交易的读集对应的键的第二键值;基于第一交易的读集,与第二键值,得到第一交易的合法性。
在该实施方式中,从状态数据库获取数据,来同时验证多个交易的合法性。也就是说,多个交易的合法性验证可以并发执行,从而进一步减少了完成整个区块中交易合法性验证所需的时长,进一步降低了区块上链的时延,提高了区块链系统的性能。
第二方面,提供了一种数据处理装置,包括:用于实现第一方面提供的方法的功能单元。
第三方面,提供了一种区块链节点,包括处理器、存储器;存储器用于存储计算机程序;处理器用于执行计算机程序,以实现第一方面提供的方法。
第四方面,提供了一种区块链系统,其特征在于,包括第四方面提供的区块链节点、背书节点和排序节点。
第五方面,提供了一种计算机存储介质,其特征在于,计算机存储介质上存储有计算机程序,当计算机程序由处理器执行时,实现第一方面提供的方法。
第六方面,本申请实施例提供了一种计算机程序产品,包括用于实现如第一方面所提供的方法的程序。
本申请实施例提供的方案,仅需要一些内存的开销和计算资源,可以快速完成待上链区块中交易的隔离性验证,大大降低了待上链区块中交易隔离性验证所需时长,加快了区块上链的速度,提高了区块链系统的性能。并且,该方案在对交易进行隔离性验证时,受状态数据库中的数据规模影响较小,使得隔离性验证的速度不会随着状态数据库中数据规模的增大而变化,保证了区块链系统长久运行地性能稳定性。以及,该方案通过内存中缓存的数据,来进行待上链区块中交易的隔离性验证,避免了交易隔离性验证对存储器的占用,减少了对状态数据库的影响,还加快了区块上链的速度,有助于区块链系统在复杂业务场景下的高性能运行。
附图说明
图1为本申请实施例提供的一种区块链系统结构示意图;
图2为并行执行的交易提交示意图;
图3为一种交易隔离性验证方法流程图;
图4为本申请实施例提供的一种数据处理方法示意图;
图5为本申请实施例提供的一种能够修改待上链区块中交易读集的交易所在区块示意图;
图6为本申请实施例提供的一种隔离性验证方案流程图;
图7A为本申请实施例提供的一种隔离性验证方案流程图;
图7B为本申请实施例提供的一种数据处理方法流程图;
图8A为本申请实施例提供的一种隔离性验证方案流程图;
图8B为本申请实施例提供的一种数据处理方法流程图;
图9为本申请实施例提供的一种数据处理方法流程图;
图10为本申请实施例提供的一种数据处理方法流程图;
图11为本申请实施例提供的一种数据处理方法流程图;
图12为本申请实施例提供的一种数据处理装置结构示意图;
图13为本申请实施例提供的一种区块链节点结构示意图。
具体实施方式
下面将结合附图,对本申请实施例中的技术方案进行描述。显然,本说明书所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。
区块链为一种链式数据结构,其由多个数据区块串接而成。区块链可以理解为一种账本,区块链中的一个数据区块相当于账本中的一页。数据区块也可以简称为区块(block),记录了交易数据。其中,每个区块可以包含交易数据、时间戳以及前一个区块的哈希值等信息。区块链技术可以借助密码学保护区块中记录的信息。基于区块链技术,能够让两方或更多方有效地记录交易数据,实现交易数据不可伪造和永久可查验。
预执行架构为一种区块链架构。在采用该架构的区块链系统(Fabric区块链)中,区块上链需要经过交易预执行(execute)步骤、排序(order)步骤以及验证(validate)步骤,以保证记录到区块中的交易数据的一致性(consistency)。
图1示出了一种预执行架构下的区块链系统。该区块链系统可以包括至少一个客户端节点(例如客户端节点101)、至少一个背书节点(例如背书节点102、背书节点103)、至少一个排序节点(例如排序节点104)以及至少一个账本节点(例如账本节点105、账本节点106)。
其中,在下文描述中,当对客户端节点、背书节点、排序节点、账本节点不做特别区分时,它们可以被简称为区块链节点或者节点。当对背书节点102、背书节点103不做特别区分时,它们可以被简称为背书节点。当对账本节点105、账本节点106不做特别区分时,它们可以被简称为账本节点。
此外,图1所示的区块链系统可以维护或者说记录一条区块链,也可以维护或者说记录多条区块链。在下文描述中,如无特殊说明,所提到的区块高度都是同一条区块链上的区块高度。
在一些实施例中,区块链节点可以为物理设备,例如服务器或终端设备。在一些实施例中,区块链节点可以为虚拟设备。其中,虚拟设备可以虚拟机(virtual machine,VM)、容器(container)等通过软件虚拟出来的运行环境,该概念包括虚拟机、容器。在一些实施例中,区块链节点可以为进程(process)或者线程(thread)。其中,进程是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位。线程是操作系统能够进行运 算调度的最小单位。线程被包含在进程之中,是进程中的实际运作单位。
客户端节点是代表用户的实体。客户端节点可以在用户的操作下,和区块链系统中的其他节点进行信息交互,例如发起交易、在区块链系统中创建智能合约等。以发起交易为例,客户端节点可以构建背书服务请求,背书服务请求的作用是请求背书节点调用智能合约来预执行或者说模拟执行交易,并对交易预执行结果进行背书。客户端节点可以向背书节点发送背书服务请求。
背书节点也可以称为合约执行节点或者说合约预执行节点。背书节点在接收到背书服务请求后,可以响应背书服务请求,调用智能合约来模拟执行交易。其中,在模拟执行交易时,读取数据键值。其中,数据键值包括键(key),键值(value)。在一个例子中,键可以代表账户,键值可以代表账户中的余额。例如,键为x,键值代表账户余额,例如x=100。其中,读取的数据键值代表了交易执行前的交易双方的账户中的余额。读取的键以及键值可以称为读集。模拟执行完交易后,可以生成写集。写集包括写入的数据键值。以键代表账户,键值代表账户中的余额为例而言,写入的数据键值代表了交易执行后的交易双方的账户中的余额。以图2所示的交易A1为例,读取的数据键值为:x=100,y=0。其中,x、y代表交易双方的键,x=100代表键x的键值为100,y=0代表键y的键值为0。写入的数据键值为:x=100-20=80,y=y+20=20。
另外,读集和写集可以统称为读写集。另外,读集也可以被称为读写集,写集也可以称为读写集。如无特殊说明,读写集可以指读集和写集,也可以指读集,也可以指写集。示例性的,读写集采用一种预设的数据结构,包括用于填充读集的字段F1和用于填充写集的字段F2。即字段F1和字段F2属于或者包含于读写集。其中,字段F1中填充的数据可以为读集,字段F2中填充的数据可以称为写集。
背书节点对交易的读写集签名,并将签名后的读写集发送至客户端节点。
通常而言,需要多个背书节点对一个交易进行背书。如此,客户端节点会从多个背书节点收到签名后的读写集。客户端节点可以按照预设的数据结构,将从多个背书节点收到签名后的读写集封装起来,这个过程可称之为构造交易数据。客户端节点将封装后的读写集发送至排序节点。
排序节点也可以称为共识节点,可以对在一段时间内接收到的多个交易的读写集进行排序。具体而言,排序节点可以根据预设的共识算法,确定该多个交易的交易序号,并根据交易序号,对该多个交易进行排序。然后,将排序后的交易的读写集等相关信息打包成区块,并将区块发送至账本节点。
账本节点可以对接收到的区块所包含的交易的读写集进行隔离性验证,以保证不同交易之间的相互独立。隔离性是指当多个用户并发访问数据库时,比如操作同一张表时,数据库为每一个用户开启的事务(其中,在区块链系统中,事物是指交易),不能被其他事务的操作所干扰,多个并发事务之间要相互隔离。如此,在区块上链(即串接到区块链上或者说写入账本)之前,需要对区块中的交易进行隔离性验证,例如,对区块中的交易进行多版本并发控制(multi-version concurrency control,MVCC)。其中,对于区块中记录的一个交易而言,当其隔离性验证通过时,该交易可以被标记为合法交易。当该交易没有通过隔离性验证时,该交易可以被标记为不合法交易。
可以设定交易A1和交易A2为并发执行的两个交易。如图2所示,交易A1和交易A2的读集相同,交易A2的读写集先上链,即交易A2先于交易A1被区块链系统确认。交易A2修改了键x的键值,交易A1仍然按照其读集(即被交易A2修改前的键值),执行交易,导 致交易A1的读集和实际的键值不一致。若仍然将交易A1标记为合法交易,那么包含交易A1的写集的区块上链后,交易A1的写集会覆盖先上链的交易A2的写集,导致交易A2的写集丢失。因此,为了避免这种情况的出现,在区块上链之前,对区块所包含的交易的读写集,进行隔离性验证。
在本申请实施例中,为了方便描述,交易的读集和隔离性验证时的实际键值不一致这一现象可以称为交易的读集冲突。
在一种方案中,通过从账本节点的状态数据库读取数据,用来验证待上链的区块中记录的交易的隔离性。其中,账本节点的状态数据库存储了已上链的区块所包含的交易的写集,即已被区块链系统确认的最新键值。其中,隔离性验证包括两部分,一是判断同一区块中的交易是否具有依赖关系,二是判断交易的读集是否被已提交的交易修改。其中,已提交的交易是指已上链的交易,即已提交的交易包含在了区块链中。
参阅图3,区块在上链之前,先判断该区块中的交易是否具有依赖关系。其中,在同一区块中,在排序好的交易序列中,若后序交易的读集键与前序交易的写集键一致,那么这两个交易之间具有依赖关系,后序交易的读集依赖前序交易的写集。若对于具有依赖关系的两个交易,在前序交易合法的情况下,可以确定后序交易存在读集冲突的交易,隔离性验证不通过,即后序交易不合法。区块中一个交易不依赖其前序交易或者所依赖的前序交易不合法,则从状态数据库中获取该交易对应的账户的最新键值。然后,判断该账户的最新键值和该交易读集中该账户的键值是否一致。若一致,则该笔交易的读集没有被已提交的交易所修改,该笔交易合法;不一致,则该笔交易不合法。接着,进行同区块中下一笔交易的隔离性验证,直到对区块中所有的交易进行了隔离性验证。
图3所示的方案需要从状态数据库获取数据,随着区块链上的区块越来越多,账本节点的状态数据库中存储的数据越来越多,导致状态数据库数据检索、查询性能衰减,导致隔离性验证占据的时长较大,进而影响区块链系统的性能。并且,在图3所示的方案中,验证执行单元与数据库的交互会带来处理器和存储器的开销。当有大量区块需要上链时,节点的硬件资源开销较大。以及图3所示的方案,串行执行区块中多个交易的隔离性验证,导致完成整个区块中交易的隔离性验证所需的时长较大,这也影响了区块链系统的性能。
本申请实施例提供了一种数据处理方法,账本节点可以缓存n个已上链区块,并利用该n个已上链区块中交易的写集,验证待上链区块中的交易的读集是否和已上链交易的写集冲突,即判断待上链区块中的交易的读集是否被已上链交易所修改。其中,已上链区块是指已经串接到区块链上的区块,即已上链区块也可以称为已落盘区块,是指已提交的、被区块链系统确认的区块。已上链交易也可以称为已提交交易,是指包含在已上链区块中的交易。缓存的n个已上链的区块是指相对待上链区块的打包出块时刻,最近上链的n个区块。举例而言,设定待上链区块的打包出块时刻为时刻T1,该n个区块中的第一个区块的上链时刻距离时刻T1最近,第二个区块的上链时刻和时刻T1之间的时长仅大于第一个区块的上链时刻和时刻T1之间的时长,第三个区块的上链时刻和时刻T1之间的时长仅大于第一个区块的上链时刻和时刻T1之间的时长、第二个区块的上链时刻和时刻T1之间的时长,依次类推。待上链区块是指还没有串接到区块链,即将或者正在进行隔离性验证的区块。待上链区块中的交易可以称为待上链交易或待提交交易。若待上链区块中的交易完成了隔离性验证,则该区块可以上链,即串接到区块链上。其中,区块的打包出块也可以称为共识出块,是指将至少一个交易的读写集等相关信息打包成区块。其中,为方便描述,区块包含交易的读写集等相关信息,可以称之为:区块包含或者说包括交易。
如此,账本节点可以利用缓存中数据,判断出待上链的区块中的交易的读集是否和已上链交易的写集冲突,无需从状态数据库获取数据,可以降低隔离性验证所占据的时长,降低区块上链的时延,提高了区块链系统的性能。并且,降低了处理器和存储器之间的通信开销,节省硬件资源。并且,该n个已上链的区块可以被同时用于对多个交易的隔离性验证,也就是说,多个交易的隔离性验证可以并发执行,从而进一步减少了整个区块完成隔离性验证所需的时间,进一步降低了区块上链的时延,提高了区块链系统的交易性能。
接下来,对本申请实施例提供的数据处理方法进行示例说明。
参阅图4,客户端节点101可以执行步骤401,向背书节点102和背书节点103发送背书服务请求。
背书节点102可以响应客户端节点101发送的交易C1的背书服务请求,预执行或者说模拟执行交易C1。其中,背书节点102在开始预执行交易C1时,获取背书节点102的当前最大的区块高度S h1,并基于区块高度S h1获取交易C1的读集,以及基于该读集,预执行交易的合约业务流程,得到写集。进而得到交易C1的读写集22。背书节点102可以对读写集22和区块高度S h1签名,即在读写集22和区块高度S h1签上签名21。然后,将签名21、读写集22和区块高度S h1通过402a发送至客户端节点101。其中,前文描述的过程可以称为背书节点102对交易C1的背书过程。签名21、读写集22和区块高度S h1可以统称为背书节点102对交易C1的背书结果。
其中,在本申请实施例中,可以将“预执行交易的合约业务流程”简称为预执行交易。
同理,背书节点103也可以响应客户端节点101发送的交易C1的背书服务请求,预执行或者说模拟执行交易C1。其中,背书节点103在开始预执行交易C1时,获取背书节点103的当前最大的区块高度S h2,并基于区块高度S h2获取交易C1的读集,以及基于该读集,预执行交易,得到写集。进而得到交易C1的读写集32。背书节点103可以对读写集32和区块高度S h2签名,即在读写集32和区块高度S h2签上签名31。然后,将签名31、读写集32和区块高度S h2通过402b发送至客户端节点101。其中,前文描述的过程可以称为背书节点103对交易C1的背书过程。签名31、读写集32和区块高度S h2可以统称为背书节点103对交易C1的背书结果。
应对理解,通过而言,背书节点也可以用作账本节点,存储有区块链,即存储有账本。对于不具有账本节点功能的背书节点,可以从账本节点获取区块链,或者说,账本节点可以向背书节点同步区块链。例如,账本节点可以在每当有区块上链时,向背书节点同步包含新上链区块的区块链。如此,背书节点可以根据其自身存储的区块链,获取背书节点的最大区块高度。
另外,为方便描述,可以将背书节点开始预执行交易C1时,获取的背书节点的当前最大的区块高度,称为交易C1的背书时最大区块高度。对于交易C1而言,一个背书节点可以获取一个背书时最大区块高度,多个背书节点可以获取多个背书时最大区块高度。
应当理解的是,上文仅对交易C1的背书节点对交易C1进行背书过程进行了示例说明,并非限定交易C1的背书节点的个数。背书节点102、背书节点103在为交易C1背书的同时,其他节点也可以为交易C1背书,具体背书过程与背书节点102的背书过程类似,此处不再一一列举。
客户端节点101可以接收到多个背书节点发送的针对交易C1的背书结果,如此可以接收到针对交易C1的多个背书结果,其中,多个背书结果和多个背书节点一一对应。客户端节点101可以基于该多个背书结果,构造交易数据。
具体而言,客户端节点101可以先验证多个背书结果中的读写集是否相同。若相同,即若不同背书结果中的读写集是相同的,则客户端节点101按照预设的数据结构D1,将交易C1的读写集填写到该数据结构D1中预设的字段中。示例性的,由于已验证了不同背书结果中交易C1的读写集是相同的,可以在该数据结构D1中填写一份读写集,无需将每个背书结果中的读写集都填写到该数据结构D1中。
客户端节点101可以将背书结果中的区块高度和签名填写到数据结构D1中具有对应关系的字段中(即对应保存或者记录来自同一背书结果的区块高度和签名)。可以理解,签名用于表示区块高度的合法性,因此,需将将签名和区块高度对应保存。示例性的,可以理解,不同背书节点开始预执行交易C1的时刻可能不同,以及在同一时刻不同背书节点中的区块链也不一定完全一致。因此,不同背书结果中,区块高度可能是不同的。可以将每个背书结果中的区块高度和签名对应填写到数据结果D1中。
如此,可以客户端节点101完成交易C1的交易数据的构造。即构造的交易数据包括交易数据包括交易C1的读写集、背书节点预执行交易时的最大区块高度(例如背书节点102预执行交易C1时的区块高度S h1,背书节点103预执行交易C2时的区块高度S h2)、以及背书节点的签名。
客户端节点101可以通过步骤403,将构造的交易C1的交易数据发送至排序节点104。排序节点104可以根据在时间段T2接收到的多个交易的交易数据,产生区块B1,或者说共识出块。其中,排序节点104可以将在时间段T2接收到的多个交易的读写集等相关信息打包为区块B1中,即产生区块B1。在一些实施例中,排序节点104可以根据预设的共识算法,确定在时间段T2接收到的多个交易中每个交易的交易序号。然后,根据交易序号,对该多个交易进行排序。再将排序后的交易的读写集等相关信息打包成区块B1,即将时间段T2接收的交易数据中的读写集等相关信息包含到区块B1中。其中,时间段T2的时长可以预先设定的。客户端节点101接收交易C1的交易数据的接收时刻位于时间段T2中。也就是说,交易C1的读写集等相关信息包含在区块B1中。
在一些实施例中,可以将交易的交易数据打包到区块B1中,即将交易的读写集、交易对应的背书时的区块高度(例如交易C1的区块高度S h1、区块高度S h2)同时打包到区块B1中。
在一些实施例中,可以将交易的读写集打包到区块B1中,而不将交易对应的背书时的最大区块高度打包到区块B1中。如此,可以适应当前的区块的数据结构,无需对区块的数据结构进行修改。
排序节点104可以获取区块B1产生时的排序节点104的最大区块高度B h。应对理解,通过而言,排序节点也可以用作账本节点,存储有区块链,即存储有账本。对于不具有账本节点功能的排序节点,可以从账本节点获取区块链,或者说,账本节点可以向排序节点同步区块链。例如,账本节点可以在每当有区块上链时,向排序节点同步包含新上链区块的区块链。如此,排序节点可以根据其自身存储的区块链,获取排序节点的最大区块高度。
排序节点104可以通过步骤404,将区块B1所包含交易的读写集、区块B1所包含的交易对应的背书时的区块高度(例如交易C1的区块高度S h1、区块高度S h2)、区块高度B h发送至账本节点105。在一些实施例中,若区块B1包含了交易的读写集、交易对应的背书时的最大区块高度。那么在步骤404中,排序节点104具体可以将区块B1和区块高度B h发送至账本节点105。在一些实施例中,若区块B1包含了交易的读写集,而不包含交易对应的背书时的最大区块高度。那么在步骤404中,排序节点104具体可以将区块B1、区块B1所包含的 交易对应的背书时的区块高度(例如交易C1的区块高度S h1、区块高度S h2)、区块高度B h发送至账本节点105。
账本节点105可以基于区块高度B h以及区块B1所包含的交易对应的背书时的区块高度,利用账本节点105缓存的数据,确定交易在被背书节点预执行时到该交易被打包成区块时的这段时间中,该交易的读集是否被修改,从而可以高效地完成交易的隔离性验证。
其中,其他账本节点,例如账本节点106,可以参考账本节点105对交易隔离性验证的方案,独立对交易进行隔离性验证。此处不再一一赘述。
接下来,以账本节点105对交易C1进行隔离性验证为例,示例介绍本申请实施例提供的数据处理方法。
在本申请实施例提供的数据处理方法中,对交易C1进行合法性验证的实质是:在包括交易C1的区块落盘时,判断交易C1是否被已落盘区块中的交易所修改,即交易C1的读集是否和已落盘区块中的交易的写集冲突。其中,不难理解,有可能修改交易C1的读集的交易的落盘时间在交易C1背书之后。因此,在包括交易C1的区块落盘时,对交易C1进行的合法性验证,需要找出或者说确定在交易C1背书后落盘的已落盘区块,并利用该已落盘区块中的写集,验证交易C1的合法性。换言之,本申请实施例提供的数据处理方法是通过判断从交易C1被背书节点预执行(即背书)时开始,到包含交易C1的区块B1上链时为止前的这一时间段内上链的区块中的交易的是否修改了交易C1的读集,即判断交易C1的读集是否和这一时间段内上链的交易的写集冲突,来实现交易C1的隔离性验证。其中,已上链交易是指已包含在已上链区块中的交易。
另外,不难理解,由于是在包括交易C1的区块落盘时,且还未完成落盘的情况下,找出或者说确定在交易C1背书后落盘的已落盘区块。因此,找出或确定的交易C1背书后的落盘的已落盘区块具体是指:在从交易C1背书时到包含交易C1的区块落盘时的这一时间段内落盘的区块。
而区块链是一种分布式系统,没有全局统一的时间戳,因此,难以直接使用时间戳来表示交易C1被背书节点预执行到包含交易C1的区块B1上链这一时间段。为此,本申请实施例采用了区块高度,来代表交易C1被背书阶段预执行时的时刻或者说时间戳。采用区块高度代表从交易C1被背书节点预执行时开始,到包含交易C1的区块B1上链时为止的这一时间段。
对于区块链上的一个区块而言,区块高度是指该区块链中该区块和创世区块(该区块链的第一个区块)之间的块数。区块高度可以用作区块链上区块的编号,用于标识该区块。当需要查询某个区块时,可以根据它的区块高度,查询该区块。其中,最大的区块高度代表了最晚串接到区块链上的区块,即最大的区块高度为最晚串接到区块链上的区块的区块高度。最大的区块高度的值等于区块链上串接的区块的个数。区块链的最大的区块高度随着串接到区块链上的区块个数的增加而变化。最小的区块高度代表区块链上的第一个区块,即创世区块。另外,需要指出的是,通常而言,在区块链系统中,最小的区块高度是0,而非1。换言之,区块高度是从0开始计数的。
结合以上描述,不难理解,对于同一条区块链而言,其中的某个区块的区块高度代表了该区块的落盘时间,不同区块的落盘时间不同,区块高度也不同。也就是说,对于同一条区块链而言,一个区块高度可以理解为或者代表了一个特定时刻,该区块链的最大区块高度代表了当前时刻。每当一个区块落盘,则最大区块高度随之变化,相当于时间向前流动。即最大区块高度的变化可以代表时间的变化。因此,交易C1背书时的区块链系统的最大区块高 度,可以代表交易C1是在何时被背书的,即代表交易C1的读集是何时被读取到的。
另外,多个已落盘区块对应的区块高度中的每个区块高度代表了相应的区块是何时落盘。若交易C1背书时的区块链系统的最大区块高度落入到了多个已落盘区块对应的区块高度范围,说明在交易C1背书后落盘的区块包括在了该多个已落盘区块中。如此,可以利用该多个已落盘区块中交易的写集,得到交易C1的合法性。
可以使用S h代表交易C1在被背书节点预执行时的最大区块高度,S h可以在区块高度S h1、区块高度S h2取值。在一些实施例中,S h是指交易C1的所有背书时最大区块高度中的最小值。设定区块高度S h1、区块高度S h2为交易C1的所有背书时的最大区块高度,那么S h具体可以是区块高度S h1、区块高度S h2中的最小值。
可以理解,S h为交易C1在被背书节点预执行时的最大区块高度,B h为产生包含交易C1读写集的区块B1时的最大的区块高度,S h小于B h。若交易C1的读集被已上链交易C2所修改,那么修改交易C1的读集的交易C2所在区块的区块高度位于区间[S h,B h]中。
参阅图5,账本节点105可以缓存区块高度区间为[B h-n+1,B h]的n个已上链区块以及n个已上拉区块对应的区块高度。其中,n为大于或等于1的整数。其中,n可以为预设值。开发者可以根据账本节点的性能自由设置n的大小。缓存数据是指内存记录数据,是指数据仍记录在内存中。另外,在区块B1上链或者说串接到区块链上之前,需要先对区块B1中的交易进行隔离性验证。因此,排序节点104在区块B1共识出块时的最大的区块高度B h,在从区块B1共识出块时到区块B1隔离性验证时这段时间,是不变的。当区块B1通过隔离性验证,串接到区块链上时,最大的区块高度B h才更新。如此,在账本节点105在从区块B1共识出块时到区块B1隔离性验证时这段时间,缓存的区块高度区间为[B h-n+1,B h]的n个已上链区块为:相对待上链区块的打包出块时刻,最近上链的n个区块。
其中,在本申请实施例中,交易的隔离性验证包括验证该交易的读集是否和已上链交易的写集冲突。
已上链区块也可以称为已落盘区块。
在一些实施例中,参阅图5,为了减少内存的开销,可以仅缓存该n个已上链区块中交易的写集。
基于上文描述,本申请实施例的方案流程如下。
参阅图6,账本节点105可以执行步骤602,判断区块高度S h是否大于或等于B h-n+1。若S h大于或等于B h-n+1,那说明区间[S h,B h]包含于区间[B h-n+1,B h]。因此,若修改交易C1读集的交易C2存在的话,那交易C2所在区块的区块高度位于区间[B h-n+1,B h]中。而区块高度在区间[B h-n+1,B h]的区块的相关数据(例如写集)仍记录在账本节点105的缓存中,如此,可以根据缓存中的区块中的交易的写集,验证交易C1的读集是否和已上链交易的写集冲突。
具体而言,可以利用区块高度位于区间[S h,B h]中的区块中的交易的写集,验证交易C1的读集是否和已上链交易的写集冲突。
其中,可以在区块高度位于区间[S h,B h]中的区块所包括的写集中,查找交易C1的读集的键的值。当在区块高度位于区间[S h,B h]中的区块中查找到交易C1的读集的键,且查找到的键的值和交易C1的读集的键值不一致,则可以确定交易C1的读集的键值已被修改。交易C1的隔离性验证不通过,即交易C1不合法。在一个例子中,对于不合法的交易,可以修改标志位,以将其标识为不合法。
另外,如上所述,区块B1是对排序好的交易进行打包而产生的,在排序好的交易序列 中,若后序交易的读集键与前序交易的写集键一致,即后序交易的读集中的账户和前序交易中写集的账户相同,那么这两个交易之间具有依赖关系,后序交易的读集依赖前序交易的写集。其中,为方便描述,可以将“后序交易的读集依赖前序交易的写集”简称为“后序交易依赖前序交易”。
在一些实施例中,若在区间[S h,B h]中的区块所包括的写集中,没有查找到交易C1的读集的键;或者,查找到键,而查找到的键值和交易C1的读集的键值一致。在这种情况下,若交易C1的读集不依赖区块B1中的其他交易的写集,那么可以确定交易C1的隔离性验证通过,即交易C1合法。若交易C1的读集依赖区块B1中的其他交易的写集,即区块B1中存在与交易C1具有依赖关系的交易,且交易C1为具有依赖关系的交易中的后序交易。那么当交易C1所依赖的交易为合法交易时,交易C2被确定为不合法交易;当交易C1所依赖的交易为不合法交易时,交易C1可以确定为合法交易。也就是说,对于具有依赖关系的两个交易,当前序交易合法时,后序交易一定不合法;当前序交易不合法时,后序交易在不和已上链交易冲突的情况下合法。
继续参阅图6,在一些实施例中,在执行步骤602之前,可以先执行步骤601,确定为交易C1的所有背书时最大区块高度中的最小值。设定区块高度S h1、区块高度S h2为交易C1的所有背书时的最大区块高度,那么S h具体可以是区块高度S h1、区块高度S h2中的最小值。
利用交易C1的所有背书时最大区块高度中的最小值,来确定用于验证交易C1的读集是否和已上链交易的写集冲突的区块,可以避免部分背书节点作恶或者说造假,所导致的验证结果不正确。具体而言,只要交易C1至少一个背书节点没有作恶或者说造假,即至少一个背书节点的背书时最大区块高度是正确的,那么正确的背书时最大区块高度或者为所有背书时最大区块高度中的最小值,或者大于所有背书时最大区块高度中的最小值。也就是说,区间[正确的背书时最大区块高度,B h]包含于或者等于区间[所有背书时最大区块高度中的最小值,B h]。如此,在否S h大于或等于B h-n+1时,若修改交易C1读集的交易C2存在的话,那交易C2所在区块的区块高度位于区间[所有背书时最大区块高度中的最小值,B h]中。
换个角度而言,若不选择交易C1的所有背书时最大区块高度中的最小值,而是选择交易C1的所有背书时最大区块高度中的任意区块高度S hx,来确定用于验证交易C1的读集是否和已上链交易冲突的区块。那么可能会出现如下情况:
选择的区块高度S hx为造假的区块高度,且大于其他背书时最大区块高度,那么确定出的区间[S hx,B h]不能全部覆盖在交易C1被背书节点预执行之后,且在区块B1共识出块之前上链的区块,从而导致用于验证交易C1的区块有遗漏。当修改交易C1的交易C2包含在遗漏的区块中时,会导致交易C1的隔离性验证结果出错。
在一些实施例中,继续参阅图6,若S h小于B h-n+1,那说明区间[S h,B h]不包含于区间[B h-n+1,B h]中。若修改交易C1读集的交易C2存在的话,那交易C2所在区块的区块高度不一定位于区间[B h-n+1,B h]中。如此,账本节点105可以执行步骤604,从状态数据库中获取交易C1读集的键键值,并利用该键值,验证交易C1的读集是否和已上链交易的写集冲突。其中,当从状态数据库中获取的交易C1对应的键值和交易C1的读集一致时,则交易C1的读集没有被已上链交易所修改,即交易C1的读集不和已上链交易的冲突。否则,交易C1不合法。
在一些实施例中,区块B1可以包括交易C1在内的多个交易。可以同时该多个交易中的至少两个交易的隔离性。也就是说,在验证交易C1的隔离性的同时,还可以验证区块B1中其他交易的隔离性。在一个示例中,区块B1中的所有交易的隔离性可以被同时验证。其中, 不同交易的隔离性验证方案可以相同,也可以不相同。
在一些实施例中,可以采用图6所示的方案,同时验证多个交易的隔离性,即在采用图6所示的方案验证交易C1的同时,利用图6所示的方案验证其他交易的隔离性。
例如区块B1还可以包括交易C3的相关数据,即包括交易C3。账本节点105缓存中的n个已上链区块,不但可以用于验证交易C1的读集是否和已上链交易的写集冲突,还可以验证交易C3的读集是否和已上链交易的写集冲突。
在一些实施例中,在利用n个已上链区块验证交易C1的读集是否和已上链交易的写集冲突的同时,还可以利用n个已上链区块验证交易C3的读集是否已上链交易的写集冲突。如此,可以实现多个交易的隔离性验证并发执行,可以降低区块B1隔离性验证所占据的时长,提高隔离性验证的效率。区块链节点通常部署在计算性能较高的服务节点上,多个交易的隔离性验证并发执行可以充分利用服务节点的硬件计算资源,提高了服务节点的吞吐量,可以满足大规模、高并发的业务场景。
在一些实施例中,可以采用图6所示的方案,在验证交易C1的隔离性的同时,可以采用其他隔离性验证方案,验证其他交易(例如交易C3)的隔离性。例如,在采用图6所示的方案验证交易C1的隔离性的同时,可以从状态数据库中交易C3的读集对应的键的键值,并利用获取的键值,验证交易C3的隔离性。其中,具体可以参考上文对图3所示实施例的介绍。
在一些实施例中,可以从状态数据库中交易C1的读集对应的键的键值,并利用获取的键值,验证交易C1的隔离性。与此同时,从状态数据库中交易C3的读集对应的键的键值,并利用获取的键值,验证交易C3的隔离性。
在本申请实施例对同时验证多个交易隔离性的方案中,每个交易的隔离性验证的具体方式不做限定。
另外,继续参阅图6,为方便描述,可以将步骤601、步骤602、步骤603、步骤604统称为:根据待上链交易的背书时的最大区块高度,验证待上链交易的读集是否和已上链交易的写集冲突。
在本申请实施例中,交易的隔离性验证还包括验证交易的读集是否依赖该交易所在区块中其他交易的写集。即验证一交易读集和同一区块内的另一交易的写集是否冲突。
接下来,在不同实施例中,示例介绍验证待上链交易的读集是否和已上链交易的写集冲突、验证一交易读集和同一区块内的另一交易的写集是否冲突的流程关系。
实施例1。
可以设定区块B1包含了交易C1的相关数据(读集等)、交易C3的相关数据(读集等)、交易C4的相关数据(读集等)。
如图7A所示,在对区块B1的隔离性验证过程中,可以执行步骤701a、701b、701c,即可以根据交易C1的背书时的最大区块高度,验证交易C1的读集是否和已上链交易的写集冲突;根据交易C3的背书时的最大区块高度,验证交易C3的读集是否和已上链交易的写集冲突;根据交易C4的背书时的最大区块高度,验证交易C4的读集是否和已上链交易的写集冲突。其中,步骤701a、701b、701c的具体执行过程可以参考上文对图6所示实施例的介绍,在此不再赘述。示例性的,如图7A所示,步骤701a、701b、701c可以并行执行。
如此,可以确定出区块B1中的哪些交易的读集和已上链交易的写集冲突,哪些交易的读集不和已上链交易的写集冲突。
可将读集和已上链交易的写集冲突的交易确定为不合法交易。
对于读集不和已上链交易的写集冲突的交易,例如交易C1,在步骤702中,可以验证该交易C1是否依赖区块B1中的其他交易。即验证交易C1的读集是否依赖区块B1中的其他交易的写集。其中,对于交易C1而言,其他交易是指区块B1中除交易C1之外的交易。交易的读集对其他交易写集的依赖具有可以参考上文介绍,在此不再赘述。如此,可以确定出哪些交易的读集依赖区块B1中的其他交易的写集。其中,可以参考交易C1,对于区块B1中的每一个读集不和已上链交易的写集冲突的交易,进行是否依赖区块B1中其他交易的验证。
若区块B1中的一交易的读集不和已上链交易的写集冲突,且该交易的写集不依赖区块B1中的其他交易的写集,可以确定该交易通过隔离性验证,即该交易合法。
若区块B1中的一交易的读集和已上链交易的写集冲突,可以确定该交易没有通过隔离性验证,即该交易不合法。
若区块B1中的一交易的读集不和已上链交易的写集冲突,但该交易读集依赖其他交易的写集,且在该交易所依赖的交易合法的情况下,确定该交易不合法。
当区块B1中的每个交易均经过隔离性验证后,可以将区块B1串接到区块链上,即区块B1上链。当区块B1上链后,区块B1中合法交易的写集更新到账本节点105的状态数据库中,即更新对应键的键值。不合法的交易的写集不更新到账本节点105的状态数据库中。
基于上文描述,本申请实施例提供的数据处理方法的一种整体流程可以如图7B所示。具体可以包括如下步骤。
客户端节点101可以执行步骤401,向背书节点102和背书节点103发送背书服务请求。具体实现过程可以参考上文对图4所示实施例的介绍,在此不再赘述。
背书节点102可以将签名21、读写集22和区块高度S h1通过402a发送至客户端节点101。背书节点103可以将签名31、读写集32和区块高度S h2通过402b发送至客户端节点101。具体实现过程可以参考上文对图4所示实施例的介绍,在此不再赘述。
客户端节点101可以接收到多个背书节点发送的针对交易C1的背书结果,如此可以接收到针对交易C1的多个背书结果,其中,多个背书结果和多个背书节点一一对应。客户端节点101可以基于该多个背书结果,构造交易信息。具体可以参考上文对图4所示实施例的介绍,在此不再赘述。
客户端节点101可以通过步骤403,将构造的交易C1的交易数据发送至排序节点104。排序节点104可以根据在时间段T2接收到的多个交易的交易数据,产生区块B1,或者说共识出块。其中,排序节点104可以将在时间段T2接收到的多个交易的读写集等相关信息打包为区块B1,即产生区块B1。具体可以参考上文对图4所示实施例的介绍,在此不再赘述。
排序节点104可以获取区块B1产生时的排序节点104的最大区块高度B h
排序节点104可以通过步骤404,将区块B1所包含交易的读写集、区块B1所包含的交易对应的背书时的区块高度(例如交易C1的区块高度S h1、区块高度S h2)、区块高度B h发送至账本节点105。具体可以参考上文对图4所示实施例的介绍,在此不再赘述。
账本节点105可以基于区块高度B h以及区块B1所包含的交易对应的背书时的区块高度,利用账本节点105缓存的数据,确定交易在被背书节点预执行时到该交易被打包成区块时的这段时间中,该交易的读集是否被修改,从而可以高效地完成交易的隔离性验证。具体而言,账本节点105可以在步骤701a中,验证交易C1的读集是否和已上链交易的写集冲突。在步骤701b中,验证交易C3的读集是否和已上链交易的写集冲突。在步骤701c中,验证交易C4的读集是否和已上链交易的写集冲突。具体实现过程,可以参考上文对图6所示实施例的 介绍。
然后,账本节点105可以执行步骤702,验证区块B1中的一个交易是否依赖区块B1中的其他交易。具体可以参考上文介绍,在此不再赘述。其中,对于区块B1中读集不和已上链交易的写集冲突的交易都执行步骤702,即验证是否依赖区块B1中的其他交易。
如此,可以发现区块B1中的哪些交易合法,哪些交易不合法。然后,可以将区块B1串接到区块链上,即区块B1上链。当区块B1上链后,区块B1中合法交易的写集更新到账本节点105的状态数据库中,即更新对应键的键值。不合法的交易的写集不更新到账本节点105的状态数据库中。
本实施例提供的数据处理方法,仅需要一些内存的开销和计算资源,可以快速完成待上链区块中交易的隔离性验证,大大降低了隔离性验证所占据的时长,加快了区块上链的速度,提高了区块链系统的性能。并且,本实施例提供的数据处理方法,受状态数据库中的数据规模影响较小,使得隔离性验证的速度不会随着状态数据库中数据规模的增大而变化,保证了区块链系统长久运行地性能稳定性。本实施例提供的数据处理方法,通过内存中缓存的数据,来进行待上链区块中交易的隔离性验证,避免了隔离性验证对存储器的占用,减少了对状态数据库的影响,并且,加快了区块上链的速度,有助于区块链系统在复杂业务场景下的高性能运行。此外,本实施例提供的数据处理方法,可以并行验证多个交易的隔离性,大大减少了待上链区块中交易隔离性验证所需的时长,使得待上链区块可以尽快上链,进一步提高了区块链系统的性能。
实施例2。
仍然可以设定区块B1包含了交易C1的相关数据(读集等)、交易C3的相关数据(读集等)、交易C4的相关数据(读集等)。
参阅图8A,在对区块B1的隔离性验证过程中,可以先执行步骤801,可以验证每个交易是否依赖区块B1中的其他交易。以交易C1为例,可以验证交易C1是否依赖区块B1中的其他交易。即验证交易C1的读集是否依赖区块B1中的其他交易的写集。其中,对于交易C1而言,其他交易是指区块B1中除交易C1之外的交易。交易的读集对其他交易写集的依赖具体可以参考上文介绍,在此不再赘述。如此,可以确定出哪些交易的读集依赖区块B1中的其他交易的写集。其中,可以参考交易C1,对于区块B1中的每一个交易,进行是否依赖区块B1中其他交易的验证。如此,可以发现区块B1中依赖其他交易的交易。在本申请实施例中,交易E1依赖另一交易E2,是指交易E1的读集依赖交易E2的写集。即在排序好的交易序列中,交易E1为交易E2的后序交易,或者为交易E2为交易E1的前序交易。交易E1的读集的键值和交易E2写集的键值一致。
可以设定区块B1中的交易C4依赖区块B1中的交易C3,而交易C1和交易C3不依赖区块B1中的其他交易。对于交易C1而言,其他交易是指区块B1中除交易C1之外的交易。对于交易C3而言,其他交易是指区块B1中除交易C3之外的交易。
接下来,可以先验证区块B1中不依赖其他交易的交易。举例而言,在步骤802a中,根据交易C1的背书时的最大区块高度,验证交易C1的读集是否和已上链交易的写集冲突,以及在步骤802b中,根据交易C3的背书时的最大区块高度,验证交易C3的读集是否和已上链交易的写集冲突。其中,步骤802a和步骤802b具体可以参考上文对图6所示实施例的介绍,在此不再赘述。示例性的,如图8A所示,步骤802a和步骤802b可以并行执行。
若区块B1中的一交易的读集不和已上链交易的写集冲突,且该交易的写集不依赖区块B1中的其他交易的写集,可以确定该交易通过隔离性验证,即该交易合法。
若区块B1中的一交易的读集和已上链交易的写集冲突,则该交易没有通过隔离性验证,即该交易不合法。可以判断不合法交易是否被其他交易所依赖,若不合法交易被其他交易所依赖,则可以继续验证依赖不合法交易的交易。例如,如图8A所示,交易C4依赖交易C3,而交易C3被确定为不合法交易,则可以继续执行步骤803,根据交易C4的背书时的最大区块高度,验证交易C1的读集是否和已上链交易的写集冲突。若冲突,则交易C4不合法。若不冲突,则交易C4合法。
当区块B1中的每个交易均经过隔离性验证后,可以将区块B1串接到区块链上,即区块B1上链。当区块B1上链后,区块B1中合法交易的写集更新到账本节点105的状态数据库中,即更新对应键的键值。不合法的交易的写集不更新到账本节点105的状态数据库中。
基于上文描述,本申请实施例提供的数据处理方法的一种整体流程可以如图8B所示。具体可以包括如下步骤。
客户端节点101可以执行步骤401,向背书节点102和背书节点103发送背书服务请求。具体实现过程可以参考上文对图4所示实施例的介绍,在此不再赘述。
背书节点102可以将签名21、读写集22和区块高度S h1通过402a发送至客户端节点101。背书节点103可以将签名31、读写集32和区块高度S h2通过402b发送至客户端节点101。具体实现过程可以参考上文对图4所示实施例的介绍,在此不再赘述。
客户端节点101可以接收到多个背书节点发送的针对交易C1的背书结果,如此可以接收到针对交易C1的多个背书结果,其中,多个背书结果和多个背书节点一一对应。客户端节点101可以基于该多个背书结果,构造交易信息。具体可以参考上文对图4所示实施例的介绍,在此不再赘述。
客户端节点101可以通过步骤403,将构造的交易C1的交易数据发送至排序节点104。排序节点104可以根据在时间段T2接收到的多个交易的交易数据,产生区块B1,或者说共识出块。其中,排序节点104可以将在时间段T2接收到的多个交易的读写集等信息打包成区块B1,以产生区块B1。具体可以参考上文对图4所示实施例的介绍,在此不再赘述。
排序节点104可以获取区块B1产生时的排序节点104的最大区块高度B h
排序节点104可以通过步骤404,将区块B1所包含交易的读写集、区块B1所包含的交易对应的背书时的区块高度(例如交易C1的区块高度S h1、区块高度S h2)、区块高度B h发送至账本节点105。具体可以参考上文对图4所示实施例的介绍,在此不再赘述。
账本节点105可以基于区块高度B h以及区块B1所包含的交易对应的背书时的区块高度,利用账本节点105缓存的数据,确定交易在被背书节点预执行时到该交易被打包成区块时的这段时间中,该交易的读集是否被修改,从而可以高效地完成交易的隔离性验证。具体而言,如图8B所示,账本节点105可以执行步骤801,验证区块B1中的一个交易是否依赖区块B1中的其他交易。具体可以参考上文介绍,在此不再赘述。其中,对区块B1中每个交易均执行执行步骤801,即验证该交易是否依赖区块B1中的其他交易。
对于不依赖同一区块中其他交易的交易,可以进一步验证读集是否和已上链交易的写集冲突。具体可以如图8所示,账本节点105可以在步骤802a中,进一步验证交易C1的读集是否和已上链交易的写集冲突,以及在步骤802b中,进一步验证交易C3的读集是否和已上链交易的写集冲突。其中,步骤802a和步骤802b具体可以参考上文对图6所示实施例的介绍,在此不再赘述。示例性的,如图8A所示,步骤802a和步骤802b可以并行执行。
如此,可以发现区块B1中的哪些交易合法,哪些交易不合法。然后,可以将区块B1串接到区块链上,即区块B1上链。当区块B1上链后,区块B1中合法交易的写集更新到账本 节点105的状态数据库中,即更新对应键的键值。不合法的交易的写集不更新到账本节点105的状态数据库中。
本实施例提供的数据处理方法,仅需要一些内存的开销和计算资源,可以快速完成待上链区块中交易的隔离性验证,大大降低了隔离性验证所占据的时长,加快了区块上链的速度,提高了区块链系统的性能。并且,本实施例提供的数据处理方法,受状态数据库中的数据规模影响较小,使得隔离性验证的速度不会随着状态数据库中数据规模的增大而变化,保证了区块链系统长久运行地性能稳定性。本实施例提供的数据处理方法,通过内存中缓存的数据,来进行待上链区块中交易的隔离性验证,避免了隔离性验证对存储器的占用,减少了对状态数据库的影响,并且,加快了区块上链的速度,有助于区块链系统在复杂业务场景下的高性能运行。此外,本实施例提供的数据处理方法,可以并行验证多个交易的隔离性,大大减少了待上链区块中交易隔离性验证所需的时长,使得待上链区块可以尽快上链,进一步提高了区块链系统的性能。
实施例3。
参阅图9,本实施例提供的数据处理方法的一种整体流程还可以如图9所示
参阅图9,在对区块B1的隔离性验证过程中,可以先执行步骤901,可以验证一个交易是否依赖区块B1中的其他交易。以交易C1为例,可以验证交易C1是否依赖区块B1中的其他交易。即验证交易C1的读集是否依赖区块B1中的其他交易的写集。其中,对于交易C1而言,其他交易是指区块B1中除交易C1之外的交易。交易的读集对其他交易写集的依赖具有可以参考上文介绍,在此不再赘述。其中,对区块B1中每个交易均执行步骤801,即验证该交易是否依赖区块B1中的其他交易。如此,可以确定出交易C1的读集依赖区块B1中的其他交易的写集。
当交易C1不依赖区块B1中的其他交易时,可以执行步骤902,根据交易C1的背书时的最大区块高度,验证交易C1的读集是否和已上链交易的写集冲突。具体可以参考上文对图6所示实施例的介绍。
当交易C1依赖区块B1中的其他交易,例如交易C3时,可以先验证交易C3的合法性。若交易C3合法,则确定交易C1为不合法交易。若交易C3不合法,则执行步骤902。若交易C1的读集不和已上链交易的写集冲突,则交易C1合法。否则交易C1不合法。
如此,可以完成交易C1的隔离性验证。
可以参考交易C1的隔离性验证方式,依次对区块B1中其他交易进行隔离性验证。
如此,可以发现区块B1中的哪些交易合法,哪些交易不合法。然后,可以将区块B1串接到区块链上,即区块B1上链。当区块B1上链后,区块B1中合法交易的写集更新到账本节点105的状态数据库中,即更新对应键的键值。不合法交易的写集不更新到账本节点105的状态数据库中。
本实施例提供的数据处理方法,仅需要一些内存的开销和计算资源,可以快速完成待上链区块中交易的隔离性验证,大大降低了隔离性验证所占据的时长,加快了区块上链的速度,提高了区块链系统的性能。并且,本实施例提供的数据处理方法,受状态数据库中的数据规模影响较小,使得隔离性验证的速度不会随着状态数据库中数据规模的增大而变化,保证了区块链系统长久运行地性能稳定性。本实施例提供的数据处理方法,通过内存中缓存的数据,来进行待上链区块中交易的隔离性验证,避免了隔离性验证对存储器的占用,减少了对状态数据库的影响,并且,加快了区块上链的速度,有助于区块链系统在复杂业务场景下的高性能运行。
基于上文所述的数据处理方案,本申请实施例提供了一种可以应用于区块链系统中第一节点的数据处理方法。该方法是上文所述方案的另一种表达方式,两者是相结合的。其中,第一节点可以为区块链系统中的账本节点。
如图10所示,该方法包括如下步骤。
步骤1001,获取第一交易的读集,以及获取第一区块高度,所述第一区块高度为对所述第一交易进行背书时,所述区块链系统中最大的区块高度,所述第一节点的缓存中存储有所述区块链系统中多个已落盘区块所包括的写集,以及所述多个已落盘区块对应的区块高度;
步骤1003,当所述第一区块高度在所述多个已落盘区块对应的区块高度的范围内时,则基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性。
在一些实施例中,所述多个已落盘区块对应的区块高度属于区间[B h-n+1,B h],则当所述第一区块高度大于或等于B h-n+1时,所述第一区块高度在所述多个已落盘区块对应的区块高度的范围内,其中n大于或等于1的整数,B h为大于或等于0的整数。
在一些实施例中,B h为所述第一交易所属的区块产生时,所述区块链系统中最大的区块高度。
在一些实施例中,所述方法还包括:当所述第一区块高度不在所述多个已落盘区块对应的区块高度的范围内时,则从所述第一节点的状态数据库中,获取所述第一交易的读集对应的键的第一键值;基于所述第一交易的读集,与所述第一键值,得到所述第一交易的合法性。
在一些实施例中,所述区块链系统还包括用于对所述第一交易进行背书的第一背书节点和第二背书节点,所述获取第一区块高度包括:获取第二区块高度和第三区块高度,其中,所述第二区块高度为所述第一交易被所述第一背书节点背书时,所述区块链系统中最大的区块高度;所述第三区块高度所述第一交易被所述第二背书节点背书时,所述区块系统中最大的区块高度;将所述第二区块高度和所述第三区块高度中小的那个作为所述第一区块高度。
在一些实施例中,所述方法还包括:获取第二交易的读集,所述第一交易和所述第二交易属于同一区块;在基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性的过程中,并行执行基于所述第二交易的读集得到所述第二交易的合法性。
在一些实施例中,所述基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性包括:在所述第一交易的读集与第三交易的写集冲突的情况下,所述第一交易不合法,所述第三交易包括在所述多个已落盘区块中。
在一些实施例中,所述基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性包括:在所述第一交易的读集与所述多个已落盘区块所包括的写集均不冲突的情况下,基于所述第一交易的读集和其他交易的写集,得到所述第一交易的合法性,其中,所述其他交易为所述第一交易所属区块中除所述第一交易之外的交易。
在一些实施例中,所述基于所述第一交易的读集和其他交易的写集,得到所述第一交易的合法性包括:在所述第一交易不依赖所述其他交易的写集的情况下,所述第一交易合法;或者,在所述第一交易依赖所述其他交易中的第四交易的写集,且所述第四交易不合法的情况下,所述第一交易合法;或者,在所述第一交易依赖所述其他交易中的第四交易的写集,且所述第四交易合法的情况下,所述第一交易不合法。
本申请实施例提供的方法,仅需要一些内存的开销和计算资源,可以快速完成待上链区块中交易的隔离性验证,大大降低了待上链区块中交易隔离性验证所需时长,加快了区块上 链的速度,提高了区块链系统的性能。并且,该方案在对交易进行隔离性验证时,受状态数据库中的数据规模影响较小,使得隔离性验证的速度不会随着状态数据库中数据规模的增大而变化,保证了区块链系统长久运行地性能稳定性。以及,该方案通过内存中缓存的数据,来进行待上链区块中交易的隔离性验证,避免了交易隔离性验证对存储器的占用,减少了对状态数据库的影响,还加快了区块上链的速度,有助于区块链系统在复杂业务场景下的高性能运行。
基于上文所述的数据处理方案,本申请实施例提供了一种可以应用于区块链系统中第一节点的数据处理方法。其中,第一节点可以为区块链系统中的账本节点。
如图11所示,该方法包括如下步骤。
步骤1101,获取第一交易的读集和第二交易的读集,所述第一交易和所述第二交易属于同一区块;
步骤1103,在基于所述第一交易的读集,得到所述第一交易的合法性的过程中,并行执行基于所述第二交易的读集,得到所述第二交易的合法性。
在一些实施例中,所述第一节点的缓存中存储有所述区块链系统中多个已落盘区块所包括的写集,以及所述多个已落盘区块对应的区块高度;所述方法还包括:获取第一区块高度,所述第一区块高度为对所述第一交易进行背书时,所述区块链系统中最大的区块高度;所述基于所述第一交易的读集,得到所述第一交易的合法性包括:基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性。
在一些实施例中,所述方法还包括:获取第二区块高度,所述第二区块高度为对所述第二交易进行背书时,所述区块链系统中最大的区块高度;所述基于所述第二交易的读集,得到所述第二交易的合法性包括:基于所述第二交易的读集,与所述多个已落盘区块所包括的写集,得到所述第二交易的合法性。
在一些实施例中,所述基于所述第二交易的读集,得到所述第二交易的合法性包括:从所述第一节点的状态数据库中,获取所述第二交易的读集对应的键的第一键值;基于所述第二交易的读集,与所述第一键值,得到所述第二交易的合法性。
在一些实施例中,所述基于所述第一交易的读集,得到所述第一交易的合法性包括:从所述第一节点的状态数据库中,获取所述第一交易的读集对应的键的第二键值;基于所述第一交易的读集,与所述第二键值,得到所述第一交易的合法性。
本申请实施例提供的数据处理方法,可以同时验证同一区块中的多个交易的隔离性,可以使得区块尽快落盘,提高了区块链系统的性能。
本申请实施例提供了一种数据处理装置。该装置包括用于实现图10所示方法的功能单元。参阅图12,该装置可以包括如下功能单元。
获取单元1210,用于获取第一交易的读集,以及获取第一区块高度,所述第一区块高度为对所述第一交易进行背书时,所述区块链系统中最大的区块高度,所述第一节点的缓存中存储有所述区块链系统中多个已落盘区块所包括的写集,以及所述多个已落盘区块对应的区块高度;
得到单元1220,用于当所述第一区块高度在所述多个已落盘区块对应的区块高度的范围内时,则基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性。
该装置的各功能单元可以参考图4-图10所示的方法实施例实现,例如图10所示的方法实施例,在此不再赘述。
本申请实施例提供了一种数据处理装置。该装置包括用于实现图11所示方法的功能单元。继续参阅图12,该装置可以包括如下功能单元。
获取单元1210,用于获取第一交易的读集,以及获取第一区块高度,所述第一区块高度为对所述第一交易进行背书时,所述区块链系统中最大的区块高度,所述第一节点的缓存中存储有所述区块链系统中多个已落盘区块所包括的写集,以及所述多个已落盘区块对应的区块高度;
得到单元1220,用于当所述第一区块高度在所述多个已落盘区块对应的区块高度的范围内时,则基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性。
该装置的各功能单元可以参考图4-图9以及图11所示的方法实施例实现,例如图11所示的方法实施例,在此不再赘述。
上文主要从方法流程的角度对本申请实施例提供的装置进行了介绍。可以理解的是,各个终端为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
参阅图13,本申请实施例提供了一种区块链节点1300。区块链节点1300可以执行图4-图11所示的各实施例中账本节点或者第一节点所执行的操作,例如可以执行图10所示实施例中第一节点的操作,再例如,可以执行图11所示实施例中第一节点的操作。其中,区块链节点1300可以包括处理器1310和存储器1320。存储器1320中存储有指令,该指令可被处理器1310执行。当该指令在被处理器1310执行时,区块链节点1300可以执行上述各方法实施例中账本节点或者第一节点所执行的操作,例如可以执行图10或图11所示实施例中第一节点的操作。
可以理解的是,本申请的实施例中的处理器可以是中央处理单元(central processing unit,CPU),还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、晶体管逻辑器件,硬件部件或者其任意组合。通用处理器可以是微处理器,也可以是任何常规的处理器。
本申请的实施例中的方法步骤可以通过硬件的方式来实现,也可以由处理器执行软件指令的方式来实现。软件指令可以由相应的软件模块组成,软件模块可以被存放于随机存取存储器(random access memory,RAM)、闪存、只读存储器(read-only memory,ROM)、可编程只读存储器(programmable rom,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)、寄存器、硬盘、移动硬盘、CD-ROM或者本领域熟知的任何其它形式的存储介质中。一种示例性的存储介质耦合至处理器,从而使处理器能够从该存储介质读取信息,且可向该存储介质写入信息。当然,存储介质也可以是处理器的组成部分。处理器和存储介质可以位于ASIC中。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产 生按照本申请实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者通过所述计算机可读存储介质进行传输。所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘(solid state disk,SSD))等。
可以理解的是,在本申请的实施例中涉及的各种数字编号仅为描述方便进行的区分,并不用来限制本申请的实施例的范围。

Claims (19)

  1. 一种数据处理方法,其特征在于,应用于区块链系统中的第一节点,
    所述方法包括:
    获取第一交易的读集,以及获取第一区块高度,所述第一区块高度为对所述第一交易进行背书时,所述区块链系统中最大的区块高度,所述第一节点的缓存中存储有所述区块链系统中多个已落盘区块所包括的写集,以及所述多个已落盘区块对应的区块高度;
    当所述第一区块高度在所述多个已落盘区块对应的区块高度的范围内时,则基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性。
  2. 根据权利要求1所述的方法,其特征在于,所述多个已落盘区块对应的区块高度属于区间[B h-n+1,B h],则当所述第一区块高度大于或等于B h-n+1时,所述第一区块高度在所述多个已落盘区块对应的区块高度的范围内,其中n大于或等于1的整数,B h为大于或等于0的整数。
  3. 根据权利要求2所述的方法,其特征在于,B h为所述第一交易所属的区块产生时,所述区块链系统中最大的区块高度。
  4. 根据权利要求1-3任一项所述的方法,其特征在于,所述方法还包括:
    当所述第一区块高度不在所述多个已落盘区块对应的区块高度的范围内时,则从所述第一节点的状态数据库中,获取所述第一交易的读集对应的键的第一键值;
    基于所述第一交易的读集,与所述第一键值,得到所述第一交易的合法性。
  5. 根据权利要求1-4任一项所述的方法,其特征在于,所述区块链系统还包括用于对所述第一交易进行背书的第一背书节点和第二背书节点,所述获取第一区块高度包括:
    获取第二区块高度和第三区块高度,其中,所述第二区块高度为所述第一交易被所述第一背书节点背书时,所述区块链系统中最大的区块高度;所述第三区块高度所述第一交易被所述第二背书节点背书时,所述区块系统中最大的区块高度;
    将所述第二区块高度和所述第三区块高度中小的那个作为所述第一区块高度。
  6. 根据权利要求1-5任一项所述的方法,其特征在于,所述方法还包括:
    获取第二交易的读集,所述第一交易和所述第二交易属于同一区块;
    在基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性的过程中,并行执行基于所述第二交易的读集得到所述第二交易的合法性。
  7. 根据权利要求1-6任一项所述的方法,其特征在于,所述基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性包括:
    在所述第一交易的读集与第三交易的写集冲突的情况下,所述第一交易不合法,所述第三交易包括在所述多个已落盘区块中。
  8. 根据权利要求1-6任一项所述的方法,其特征在于,所述基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性包括:
    在所述第一交易的读集与所述多个已落盘区块所包括的写集均不冲突的情况下,基于所述第一交易的读集和其他交易的写集,得到所述第一交易的合法性,其中,所述其他交易为所述第一交易所属区块中除所述第一交易之外的交易。
  9. 根据权利要求8所述的方法,其特征在于,所述基于所述第一交易的读集和其他交易的写集,得到所述第一交易的合法性包括:
    在所述第一交易不依赖所述其他交易的写集的情况下,所述第一交易合法;或者,
    在所述第一交易依赖所述其他交易中的第四交易的写集,且所述第四交易不合法的情况下,所述第一交易合法;或者,
    在所述第一交易依赖所述其他交易中的第四交易的写集,且所述第四交易合法的情况下,所述第一交易不合法。
  10. 一种数据处理方法,其特征在于,应用于区块链系统中的第一节点,所述方法包括:
    获取第一交易的读集和第二交易的读集,所述第一交易和所述第二交易属于同一区块;
    在基于所述第一交易的读集,得到所述第一交易的合法性的过程中,并行执行基于所述第二交易的读集,得到所述第二交易的合法性。
  11. 根据权利要求10所述的方法,其特征在于,所述第一节点的缓存中存储有所述区块链系统中多个已落盘区块所包括的写集,以及所述多个已落盘区块对应的区块高度;
    所述方法还包括:获取第一区块高度,所述第一区块高度为对所述第一交易进行背书时,所述区块链系统中最大的区块高度;
    所述基于所述第一交易的读集,得到所述第一交易的合法性包括:基于所述第一交易的读集,与所述多个已落盘区块所包括的写集,得到所述第一交易的合法性。
  12. 根据权利要求11所述的方法,其特征在于,所述方法还包括:获取第二区块高度,所述第二区块高度为对所述第二交易进行背书时,所述区块链系统中最大的区块高度;
    所述基于所述第二交易的读集,得到所述第二交易的合法性包括:基于所述第二交易的读集,与所述多个已落盘区块所包括的写集,得到所述第二交易的合法性。
  13. 根据权利要求12所述的方法,其特征在于,所述基于所述第二交易的读集,得到所述第二交易的合法性包括:
    从所述第一节点的状态数据库中,获取所述第二交易的读集对应的键的第一键值;
    基于所述第二交易的读集,与所述第一键值,得到所述第二交易的合法性。
  14. 根据权利要求10所述的方法,其特征在于,所述基于所述第一交易的读集,得到所述第一交易的合法性包括:
    从所述第一节点的状态数据库中,获取所述第一交易的读集对应的键的第二键值;
    基于所述第一交易的读集,与所述第二键值,得到所述第一交易的合法性。
  15. 一种数据处理装置,包括:用于实现权利要求1-9任一项所述方法的功能单元,或者,用于实现权利要求10-14任一项所述方法的功能单元。
  16. 一种区块链节点,其特征在于,包括处理器、存储器;所述存储器用于存储计算机程序;所述处理器用于执行所述计算机程序,以实现如权利要求1-6任一项所述的方法,或者如权利要求10-14任一项所述方法。
  17. 一种区块链系统,其特征在于,包括权利要求16所述的区块链节点、背书节点和排序节点。
  18. 一种计算机存储介质,其特征在于,所述计算机存储介质上存储有计算机程序,当所 述计算机程序由处理器执行时,实现如权利要求1-9任一项所述的方法或者如权利要求10-14任一项所述方法。
  19. 一种计算机程序产品,其特征在于,包括用于实现如权利要求1-9任一项所述方法或者如权利要求10-14任一项所述方法的程序。
PCT/CN2022/083235 2022-03-26 2022-03-26 一种数据处理方法、区块链节点及区块链系统 WO2023184052A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
PCT/CN2022/083235 WO2023184052A1 (zh) 2022-03-26 2022-03-26 一种数据处理方法、区块链节点及区块链系统

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2022/083235 WO2023184052A1 (zh) 2022-03-26 2022-03-26 一种数据处理方法、区块链节点及区块链系统

Publications (1)

Publication Number Publication Date
WO2023184052A1 true WO2023184052A1 (zh) 2023-10-05

Family

ID=88198493

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/083235 WO2023184052A1 (zh) 2022-03-26 2022-03-26 一种数据处理方法、区块链节点及区块链系统

Country Status (1)

Country Link
WO (1) WO2023184052A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117217945A (zh) * 2023-11-09 2023-12-12 广东海洋大学 一种基于区块链的企业财务流程管理平台
CN117670330A (zh) * 2024-02-01 2024-03-08 中国信息通信研究院 基于区块链的交易处理方法和装置、电子设备和存储介质

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109285006A (zh) * 2018-09-20 2019-01-29 中链科技有限公司 一种区块链数据的并行验证处理方法及装置
CN110533429A (zh) * 2019-08-30 2019-12-03 北京金山云网络技术有限公司 区块链中的交易背书方法、装置和区块链网络
CN111445236A (zh) * 2019-11-14 2020-07-24 杭州复杂美科技有限公司 一种区块链交易验证方法、设备及存储介质
CN112035069A (zh) * 2020-09-17 2020-12-04 上海二三四五网络科技有限公司 一种判断文件是否完整落盘的控制方法及装置
US20210318859A1 (en) * 2020-04-13 2021-10-14 International Business Machines Corporation Optimization of execution of smart contracts
CN113609222A (zh) * 2019-09-12 2021-11-05 腾讯科技(深圳)有限公司 区块链网络的证书处理方法、装置、电子设备及存储介质
CN113743950A (zh) * 2021-11-04 2021-12-03 支付宝(杭州)信息技术有限公司 在区块链中执行交易的方法、区块链节点和区块链

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109285006A (zh) * 2018-09-20 2019-01-29 中链科技有限公司 一种区块链数据的并行验证处理方法及装置
CN110533429A (zh) * 2019-08-30 2019-12-03 北京金山云网络技术有限公司 区块链中的交易背书方法、装置和区块链网络
CN113609222A (zh) * 2019-09-12 2021-11-05 腾讯科技(深圳)有限公司 区块链网络的证书处理方法、装置、电子设备及存储介质
CN111445236A (zh) * 2019-11-14 2020-07-24 杭州复杂美科技有限公司 一种区块链交易验证方法、设备及存储介质
US20210318859A1 (en) * 2020-04-13 2021-10-14 International Business Machines Corporation Optimization of execution of smart contracts
CN112035069A (zh) * 2020-09-17 2020-12-04 上海二三四五网络科技有限公司 一种判断文件是否完整落盘的控制方法及装置
CN113743950A (zh) * 2021-11-04 2021-12-03 支付宝(杭州)信息技术有限公司 在区块链中执行交易的方法、区块链节点和区块链

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117217945A (zh) * 2023-11-09 2023-12-12 广东海洋大学 一种基于区块链的企业财务流程管理平台
CN117217945B (zh) * 2023-11-09 2024-03-12 广东海洋大学 一种基于区块链的企业财务流程管理平台
CN117670330A (zh) * 2024-02-01 2024-03-08 中国信息通信研究院 基于区块链的交易处理方法和装置、电子设备和存储介质

Similar Documents

Publication Publication Date Title
EP3678346B1 (en) Blockchain smart contract verification method and apparatus, and storage medium
CN108846659B (zh) 基于区块链的转账方法、装置及存储介质
US10698885B2 (en) Method and device for writing service data in block chain system
CN107577427B (zh) 用于区块链系统的数据迁移方法、设备和存储介质
CN113329031B (zh) 一种区块的状态树的生成方法及装置
CN107392608B (zh) 基于区块链系统的数字资产交易方法及区块链系统
WO2020082871A1 (zh) 一种并行化执行区块链交易的方法、装置及系统
US20210049715A1 (en) Blockchain-based data procesing method, apparatus, and electronic device
WO2022156574A1 (zh) 基于区块链的数据处理方法、装置、设备及可读存储介质
US10108658B1 (en) Deferred assignments in journal-based storage systems
CN110046523B (zh) 智能合约校验方法及装置和电子设备
US11048669B2 (en) Replicated state management using journal-based registers
EP3961461B1 (en) Method and apparatus for obtaining number for transaction-accessed variable in blockchain in parallel
CN111882435A (zh) 在区块链中执行交易的方法及装置
US11775507B2 (en) Methods and apparatuses for reading and updating data structures, and electronic devices
CN111459948B (zh) 一种基于中心化块链式账本的交易完整性验证方法
WO2023184052A1 (zh) 一种数据处理方法、区块链节点及区块链系统
CN108062235A (zh) 数据处理方法及装置
CN114564500A (zh) 在区块链系统中实现结构化数据存储和查询的方法和系统
CN110119947B (zh) 共享工作量证明算力生成共生区块链的方法和设备
WO2024021417A1 (zh) 数据账户创建方法及装置
CN108710658B (zh) 一种数据记录的存储方法及装置
CN115203746A (zh) 数据账户的访问授权方法及装置
Choi et al. LMPTs: Eliminating Storage Bottlenecks for Processing Blockchain Transactions
CN115221559A (zh) 数据账户的访问授权方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22933911

Country of ref document: EP

Kind code of ref document: A1