WO2024016766A1 - 交易处理方法、装置、设备、存储介质和程序产品 - Google Patents

交易处理方法、装置、设备、存储介质和程序产品 Download PDF

Info

Publication number
WO2024016766A1
WO2024016766A1 PCT/CN2023/090469 CN2023090469W WO2024016766A1 WO 2024016766 A1 WO2024016766 A1 WO 2024016766A1 CN 2023090469 W CN2023090469 W CN 2023090469W WO 2024016766 A1 WO2024016766 A1 WO 2024016766A1
Authority
WO
WIPO (PCT)
Prior art keywords
filter
expansion
blockchain
node
block
Prior art date
Application number
PCT/CN2023/090469
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 腾讯科技(深圳)有限公司
Publication of WO2024016766A1 publication Critical patent/WO2024016766A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/215Improving data quality; Data cleansing, e.g. de-duplication, removing invalid entries or correcting typographical errors
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2457Query processing with adaptation to user needs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • 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
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Definitions

  • the present disclosure relates to the fields of computer and Internet technologies, and in particular to transaction processing.
  • the so-called transaction deduplication is to determine whether the transaction already exists in the current node's ledger.
  • the purpose of this disclosure is to provide a transaction processing method, device, electronic equipment, computer-readable storage medium and program product, which can improve the deduplication accuracy of nodes.
  • the embodiment of the present disclosure provides a transaction processing method, which includes: obtaining the first block to be uploaded in the blockchain; when it is determined that the first block satisfies the first expansion condition, according to the The first expansion condition determines the first node among the nodes of the blockchain to perform filter expansion;
  • the capacity of the first expansion filter is greater than the capacity of the first processing filter in the execution node.
  • the first expansion filter is the first expansion filter.
  • a node is generated based on the transactions that have been uploaded in the blockchain; loads the transactions in the first block to the first expansion filter, and uses the first expansion filter as the second processing filter, so that the transactions to be uploaded to the blockchain are deduplicated and filtered through the second processing filter.
  • Embodiments of the present disclosure provide a transaction processing device, including: a first block acquisition module, a first node determination module, a first expansion filter determination module, and a first block loading module.
  • the first block acquisition module is used to acquire the first block to be uploaded in the blockchain; the first node determination module is used to determine that the first block meets the first expansion condition. In the case of , determine the first node to perform filter expansion among the nodes of the blockchain according to the first expansion condition; the first expansion filter determination module is used to obtain the first node from the first node.
  • An expansion filter the capacity of the first expansion filter is greater than the capacity of the first processing filter in the execution node, the first expansion filter is the first node according to the block chain generated by transactions that have been uploaded to the chain; the first block loading module is used to load the transactions in the first block to the first Expand the filter, and use the first expansion filter as a second in-process filter to deduplicate and filter the transactions to be uploaded to the blockchain through the second in-process filter.
  • An embodiment of the present disclosure proposes an electronic device, which includes: one or more processors; a storage device configured to store one or more computer programs.
  • a storage device configured to store one or more computer programs.
  • An embodiment of the present disclosure provides a computer-readable storage medium on which a computer program is stored.
  • the computer program is executed by a processor, the transaction processing method as described in any one of the above is implemented.
  • An embodiment of the present disclosure proposes a computer program product including a computer program, which when run on a computer causes the computer device to execute the above transaction processing method.
  • the execution node can realize the expansion of the filter in a timely manner when the first block meets the expansion conditions.
  • the expansion filter is built by other nodes in the blockchain, and does not occupy the resources of the execution node, and will not affect the business of the execution node ( For example, deduplication and filtering services), this will not only improve the accuracy of deduplication for nodes with lower performance (such as fewer cores) but will not have an impact on the node's own business.
  • Figure 1A is a schematic architectural diagram of a transaction processing system provided by an embodiment of the present application.
  • Figure 1B is a schematic structural diagram of a blockchain provided by an embodiment of the present application.
  • Figure 1C is a schematic diagram of a process for generating new blocks provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram of blockchain deduplication filtering according to related technologies
  • Figure 3 is a flow chart of a deduplication filtering method according to the related art
  • Figure 4 is a flow chart of a transaction processing method according to an exemplary embodiment
  • Figure 5 is a flow chart of a transaction processing method according to an exemplary embodiment
  • Figure 6 is a schematic diagram of a filter component according to an exemplary embodiment
  • Figure 7 is a schematic diagram of a blockchain according to an exemplary embodiment
  • Figure 8 is a flow chart of a transaction processing method according to an exemplary embodiment
  • Figure 9 is a flow chart of a first expansion filter determination method according to an exemplary embodiment
  • Figure 10 is a flow chart of a deduplication filtering determination method according to an exemplary embodiment
  • Figure 11 is a flow chart of a transaction processing method according to an exemplary embodiment
  • Figure 12 is a flow chart of a method for building an expansion filter according to an exemplary embodiment
  • Figure 13 is a schematic diagram of a filter assembly according to an exemplary embodiment
  • Figure 14 is a flow chart of a method for building an expansion filter according to an exemplary embodiment
  • Figure 15 is a schematic diagram of a filter assembly according to an exemplary embodiment
  • Figure 16 is a schematic diagram of a filter assembly according to an exemplary embodiment
  • Figure 17 is a flow chart of a method for modifying capacity expansion conditions according to an exemplary embodiment
  • Figure 18 is a schematic diagram of a deduplication filtering method according to an exemplary embodiment
  • Figure 19 is a schematic diagram of a deduplication filtering method according to an exemplary embodiment
  • Figure 20 is a flow chart of a method for reloading a filter according to an exemplary embodiment
  • Figure 21 is a block diagram of a transaction processing device according to an exemplary embodiment
  • FIG. 22 shows a schematic structural diagram of an electronic device suitable for implementing embodiments of the present disclosure.
  • Example embodiments will now be described more fully with reference to the accompanying drawings.
  • Example embodiments may, however, be embodied in various forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concepts of the example embodiments. To those skilled in the art.
  • the same reference numerals in the drawings represent the same or similar parts, and thus their repeated description will be omitted.
  • Words such as “first” and “second” do not limit the quantity and order of execution, and words such as “first” and “second” do not limit the number to be different; the terms “include”, “include” and “have ” is used to express an open-ended inclusion and means that there may be additional elements/components/etc. in addition to the listed elements/components/etc.;
  • embodiments of this application provide a transaction processing method that can obtain the expanded data from other nodes in a timely manner when the first block meets the expansion conditions.
  • Filter in order to improve the deduplication accuracy of the filter while reducing the resource (memory resources or disk resources) occupation of the execution node.
  • the transaction processing system includes a blockchain network 10 and a terminal device 20, where: the blockchain network 10 refers to a node for Number of nodes According to the shared network, multiple nodes 101 may be included in the blockchain network. Each node 101 can receive input information during normal operation, and maintain shared data within the blockchain network (i.e., blockchain) based on the received input information. In order to ensure information exchange within the blockchain network, there can be information connections between each node, and point-to-point (Peer To Peer, P2P) communication can be achieved between any two nodes, specifically through wired communication links or wireless communication links. road for P2P communication. For example, when any node in the blockchain network receives input information, other nodes will obtain the input information according to the consensus algorithm and store the input information as data in the shared data, so that all nodes in the blockchain network can The stored data is consistent.
  • the blockchain network 10 refers to a node for Number of nodes
  • multiple nodes 101 may be included in the blockchain network.
  • Each node 101 can receive input information
  • the terminal device 20 can access the blockchain network and communicate with nodes in the blockchain network, for example, submit transactions to be uploaded to the node, obtain data from the node, and so on.
  • the terminal device 20 may specifically be a smartphone, a tablet computer, a notebook computer, a desktop computer, a vehicle-mounted intelligent terminal, etc., which are not limited in the embodiments of this application.
  • each node in the blockchain network has a corresponding node identifier, and each node in the blockchain network can store the node identifiers of other nodes in the blockchain network, so that it can be used later based on other nodes.
  • Each node can maintain a node ID list as shown in the following table, and store the node name and node ID correspondingly in the node ID list.
  • the node identifier can be an Internet Protocol (Internet Protocol, IP) address and any other information that can be used to identify the node, such as an IP address.
  • IP Internet Protocol
  • each node in the blockchain network stores an identical blockchain.
  • the blockchain consists of multiple block groups that can be assembled according to actual needs. See Figure 1B.
  • the blockchain consists of multiple blocks.
  • the founding block includes a block header and a block body.
  • the block header stores input information characteristic values.
  • the input information is stored in the block body;
  • the next block of the genesis block has the genesis block as the parent block, and the next block also includes the block header and block body, and the block header
  • the input information characteristic value of the current block, the block header characteristic value of the parent block, version number, timestamp and difficulty value are stored in, and so on, so that the block data stored in each block in the blockchain They are all related to the block data stored in the parent block, ensuring the security of the information input in the block.
  • each block in the blockchain see Figure 1C.
  • the node where the blockchain is located receives the input information, it verifies the input information. After completing the verification, the input information is stored in the memory pool. , and updates its hash tree used to record input information; after that, the update timestamp is updated to the time when the input information is received, and different random numbers are tried, and the eigenvalues are calculated multiple times, so that the calculated eigenvalues
  • the following formula can be satisfied:
  • SHA256 is the eigenvalue algorithm used to calculate eigenvalues
  • version (version number) is the version information of the relevant block protocol in the blockchain
  • prev_hash is the block header eigenvalue of the parent block of the current block
  • merkle_root is the input information
  • the characteristic value of The value threshold can be determined based on nbits.
  • the information can be stored correspondingly, the block header and the block body are generated, and the current block is obtained.
  • the node where the blockchain is located sends the newly generated blocks to other nodes in the blockchain network where it is located based on the node identifiers of other nodes in the blockchain network, and the other nodes process the newly generated blocks. Verification, and after completion of verification, the newly generated block is added to the blockchain where it is stored.
  • smart contracts can be run on the nodes of the blockchain network.
  • Smart contracts are code implementations used to execute when certain conditions are met. Developers can define contract logic through programming languages and publish it to the blockchain (smart contract registration) , according to the logic of the contract terms, call the key or other events to trigger execution, complete the contract logic, and also provide the function of upgrading and canceling the smart contract.
  • a certain node 101 of the blockchain network can obtain the summary information of the target transaction when receiving the target transaction submitted by the terminal device 20, and use N Bloom Filters (Bloom Filter) ) Query the summary information of the target transaction from the summary information corresponding to the processed transaction.
  • N is an integer greater than or equal to 1. If the summary information of the target transaction is queried, the target transaction is determined to be a processed transaction and the target transaction is refused to be added.
  • Bloom filters can be used to efficiently and accurately check whether the submitted transaction has already appeared in the ledger, thus effectively avoiding repeated transactions.
  • FIG. 2 is a schematic diagram of blockchain deduplication filtering according to related technologies.
  • the core of the blockchain deduplication and filtering process in related technologies is to first repeatedly judge the transactions in the transaction pool through filters (such as Bloom filters or cuckoo filters). If it is judged that the transaction exists If so, a secondary judgment will be made through the database.
  • filters such as Bloom filters or cuckoo filters.
  • FIG. 3 is a flow chart of a deduplication filtering method according to the related art.
  • the above deduplication filtering method may include the following steps.
  • S308 perform deduplication judgment on the transaction object through the filter in the filtering component.
  • S310 is executed to put the transaction object into the transaction pool.
  • S312 is executed to deduplicate the transaction object through the ledger database of the blockchain.
  • the above-mentioned ledger database may refer to the ledger data on the blockchain.
  • S314 is executed to discard the transaction object.
  • filters may cause false positives in determining duplicate transactions. That is to say, if the filter thinks that there is no (negative) transaction duplication in the transaction, it must not exist. If it thinks that there is (positive) transaction duplication, it is not necessarily the case. There may or may not be transaction duplication, and further judgment (database judgment) is required. .
  • the filter itself has a shortcoming.
  • the false positive rate will become higher and higher.
  • the false positive rate of the filter will be very high.
  • most of the All transactions will be judged positive, which will lose the meaning of the filter, which will lead to judgment breakdown and direct access to the database, causing huge pressure on the database.
  • an embodiment of the present disclosure provides a transaction processing method, which can be executed by any node in any blockchain as the execution subject
  • the node may be any electronic device with computing processing capabilities.
  • the node is recorded as an execution node.
  • the execution node and the first node and the second node mentioned later are all nodes in the same blockchain.
  • Figure 4 is a flow chart of a transaction processing method according to an exemplary embodiment.
  • the transaction processing method provided by the embodiment of the present disclosure may include the following steps.
  • the first block can be a block from the transaction pool of the execution node but not yet on the chain.
  • the first expansion condition may include the number of blocks, the number of transactions, etc. set according to actual needs. For example, it may be the number of blocks or the number of transactions set according to the capacity of the filter. This disclosure There are no restrictions on this. It can be understood that the greater the capacity of the filter, the greater the number of blocks set in the first expansion condition (that is, under the same error rate, the transactions (or blocks) that a filter with a large capacity can process The greater the quantity).
  • the above-mentioned first expansion condition can be specifically: when the number of blocks in the blockchain is greater than the target block number threshold (or when the number of transactions is greater than the target number of transactions), the expansion process is performed according to the target capacity.
  • the target block number threshold or when the number of transactions is greater than the target number of transactions
  • the expansion process is performed according to the target capacity.
  • the capacity of the first expansion filter is greater than the capacity of the first processing filter in the execution node, and the first expansion filter is generated by the first node based on the transactions that have been uploaded in the blockchain.
  • the above-mentioned first expansion filter or first processing filter may be any filter that can perform deduplication filtering, such as a Bloom filter or a cuckoo filter, and the present disclosure does not limit this.
  • the Bloom filter can be a data structure that determines whether a certain data exists. This structure occupies a small memory space, but there will be a certain misjudgment rate. As the amount of data in the Bloom filter becomes larger and larger, Its misjudgment rate will become higher and higher.
  • the judgment result of the Bloom filter is a false positive, that is to say, if it is judged that a certain value does not exist, it must not exist, and if it is judged that a certain value exists, it may not exist.
  • the above-mentioned first in-process filter may run in the memory of the execution node, but the disclosure is not limited thereto.
  • the first expansion filter can be generated by a node with better performance (such as a large number of cores, large memory or large disk space) in the blockchain.
  • the blockchain can determine which nodes will construct the first expansion filter based on the performance of each node. In short, nodes with better performance can build more expansion filters, and nodes with poor performance can not build expansion filters at all, thus avoiding the impact of the construction of expansion filters on the node's business.
  • S408 Load the transactions in the first block to the first expansion filter, and use the first expansion filter as the second processing filter, so that the transactions to be uploaded to the blockchain can be processed through the second processing filter. Transactions are deduplicated and filtered.
  • the transactions in the first block can be hashed using multiple hashing algorithms, and then the calculation results are loaded into the first expansion filter.
  • the first expansion filter may be a Bloom filter.
  • the core implementation of the Bloom filter is a very large bit array and several hash functions. In some embodiments, it can be assumed that the length of the bit array is m, the number of hash functions is k, m is an integer greater than 1, and k is an integer greater than 1.
  • how to load the transactions in the first block to the first expansion filter can be explained through the following embodiment: first, initialize the bit array corresponding to the first expansion filter, and set each bit in it. Bit 0. For each transaction in the first block, the transaction is mapped through k hash functions in sequence. Each mapping will generate a hash value. This value corresponds to a point on the bit array, and then the corresponding position of the bit array is Marked as 1.
  • the same method maps W to k points on the bit array through hashing. If one of the k points is not 1, it can be judged that the element must not exist in the set. On the contrary, if k points are all 1, then the element may exist in the set.
  • the execution node can use the first expansion filter to replace the original first in-process filter, so that the execution node uses the first expansion filter to deduplicate and filter the transactions to be uploaded in the blockchain. .
  • the transactions that have been uploaded in the blockchain can be obtained; and then the first expansion is constructed based on the transactions that have been uploaded in the blockchain. filter, and use the first expansion filter as the second in-processing filter to deduplicate and filter the transactions to be uploaded to the blockchain through the second in-processing filter.
  • the technical solution provided by this embodiment is that when the first block meets the first expansion condition (for example, the error rate of the filter in the first process reaches a certain threshold), an expanded data is obtained from the first node of the blockchain.
  • the filter is used as a processing filter of the execution node to deduplicate and filter subsequent transactions on the chain.
  • the execution node can realize the expansion of the filter in time when the first block meets the expansion conditions, and continuing to perform deduplication filtering based on the expanded filter can improve the deduplication accuracy of the execution node; on the other hand,
  • the expansion filter is built by other nodes in the blockchain, does not occupy the resources of the execution node, and will not have any impact on the execution node's business (such as deduplication filtering business), which is suitable for those with lower performance ( For example, for nodes with fewer cores), the accuracy of deduplication is improved without affecting the node's own business.
  • Figure 5 is a flow chart of a transaction processing method according to an exemplary embodiment.
  • the above transaction processing method may include the following steps.
  • the capacity of the first expansion filter is greater than the capacity of the first processing filter in the execution node, and the first expansion filter is generated by the first node based on the transactions that have been uploaded in the blockchain.
  • the execution node may obtain the first in-process filter from a filter component running in memory.
  • the filtering component in the memory of the execution node may include a processing filter (for example, the first processing filter) and a ledger database.
  • the processing filter is based on the block 0 ⁇ the current
  • the ledger database can be generated based on the transactions in the blockchain.
  • the processing filter (such as the first processing filter) may refer to the Bloom filter currently deduplicating the transaction, and the Bloom filter will change as the transaction is written to the ledger;
  • the ledger database It is a database where local nodes store ledgers.
  • the error rate of the filter in the first process has reached a certain threshold, and it is not suitable to continue the deduplication filtering operation.
  • the first processing filter will be consensused in the blockchain.
  • the first in-process filter can be uploaded and stored on the chain through the following method: the execution node initiates a transaction in the blockchain to upload the first in-process filter; multiple consensuses in the blockchain
  • the node (the consensus node is a node in the blockchain) performs consensus processing on the first processing filter (for example, determines whether the first processing filter uploaded by the execution node is consistent with the first processing filter generated by itself, if If the consensus is unanimous, the consensus passes); when the number of consensus nodes that pass the consensus exceeds the target threshold, it is considered that the filter in the first process passes the consensus; in the case of the filter in the first process passing the consensus in the blockchain, the filter in the first process passes the consensus, the filter in the first process passes the consensus A processing filter is stored in the block body of the first block in the transaction pool; finally, the first block in the transaction pool is uploaded to the blockchain.
  • the first processing filter and the second processing filter can be consensus-chained at an appropriate time to facilitate traceability, increase the cost of malicious behavior of nodes or clients, and reduce the malicious behavior of nodes or clients. .
  • the first processing filter when the first block meets the first expansion condition, can be uploaded to the chain through consensus and stored in the first block, so as to facilitate subsequent traceability and increase the number of nodes doing evil (malicious refusal to upload). chain or malicious on-chain) cost, and improve the authenticity and reliability of data on the blockchain.
  • Figure 7 is a schematic diagram of a blockchain according to an exemplary embodiment.
  • some blocks in the blockchain can store filters so that when nodes or clients are found to exist Retrospect the evil deeds when you commit them.
  • the technical solution proposed in this embodiment can, on the one hand, speed up the loading process of the filter at startup by storing the first processing filter in the block; on the other hand, it can trace the evil behavior to increase the cost of the node doing evil. , thereby preventing nodes from doing evil.
  • Figure 8 is a flow chart of a transaction processing method according to an exemplary embodiment.
  • the above transaction processing method may include the following steps.
  • the capacity of the first expansion filter is greater than the capacity of the first processing filter in the execution node, and the first expansion filter is generated by the first node based on the transactions that have been uploaded in the blockchain.
  • S808 Load the transactions in the first block to the first expansion filter, and use the first expansion filter as the second processing filter, so that the to-be-chained data of the blockchain can be processed through the second processing filter. Transactions are deduplicated and filtered.
  • S812 Load the transactions in the first block to the first processing filter, so that the transactions to be uploaded to the blockchain can be deduplicated and filtered through the first processing filter.
  • the technical solution provided by this embodiment is to continue loading the first block to the processing filter in the execution node when the first block does not meet the first expansion condition (that is, the error rate of the first processing filter does not reach a certain level). threshold).
  • the first expansion condition that is, the error rate of the first processing filter does not reach a certain level). threshold.
  • the first node may be included in the plurality of nodes of the blockchain.
  • the first node can be a node in the blockchain with good device performance (such as a large number of cores, large memory, large disk, or strong computing power).
  • the first node may be one or more. In some embodiments, the first node may include a first execution node and a second execution node.
  • first execution node and the second execution node as examples to explain how to obtain the first expansion filter from the first node.
  • first node may also include a third execution node, a fourth execution node, etc.
  • Those skilled in the art can easily extend the technical solutions provided by the following embodiments to the first node and may also include a third execution node. In the case of execution node, fourth execution node...
  • Figure 9 is a flow chart of a first expansion filter determination method according to an exemplary embodiment.
  • the above-mentioned first expansion filter determination method may include the following steps.
  • a security check may be performed on the first target expansion filter provided by the first execution node.
  • the first target expansion filter can be safely detected by the following method: constructing a candidate expansion filter based on the transactions on the blockchain, and the capacity of the candidate expansion filter is equal to the first target expansion filter capacity; perform security detection on the first target expansion filter based on the candidate expansion filter.
  • security detection of the first target expansion filter can be performed through the following methods: obtaining at least one on-chain transaction from the blockchain; randomly constructing at least one virtual transaction; based on at least one on-chain transaction and at least A dummy transaction performs a security check on the first target expansion filter.
  • the first capacity expansion filter when the first capacity expansion filter passes the security inspection, the first capacity expansion filter may be directly used as the first capacity expansion filter.
  • the first node also has a third execution node and a fourth execution node, you can continue to obtain the expansion filter from the third execution node or the fourth execution node to obtain the first expansion filter.
  • the obtained first expansion filter has not been maliciously tampered with and is real and effective, thereby improving the accuracy of deduplication filtering; on the other hand, it can be obtained from multiple first nodes
  • the first expansion filter not only improves the authenticity of the first expansion filter, but also avoids problems such as low deduplication filtering efficiency caused by the execution node building the first expansion filter itself.
  • the first node may include multiple execution nodes, and the first expansion filter may be consensus among multiple execution nodes, and then sent to the execution node after the consensus is passed (if the consensus fails, it will not be sent. to the execution node); after the execution node receives the first expansion filter that has passed the consensus of multiple execution nodes, it will perform security detection on the received first expansion filter; and after passing the security detection, the first expansion filter will be
  • the processor serves as a processing filter to deduplicate and filter transactions to be uploaded to the chain. This solution can ensure that there are and are only all on-chain transactions recorded in the first expansion filter, preventing the first node from doing evil, thereby improving the effectiveness of deduplication and filtering of on-chain data on the blockchain.
  • Figure 10 is a flowchart of a deduplication filtering determination method according to an exemplary embodiment.
  • the above deduplication filtering method may include the following steps.
  • the first transaction includes a first transaction identifier.
  • the above-mentioned first transaction identifier may be Tx01, Tx02, Tx03... etc. in the block in Figure 7, and this disclosure does not limit this.
  • the first transaction identifier before deduplicating and filtering the first transaction identifier through the second in-process filter, the first transaction identifier also needs to be deduplicated and filtered through the transaction pool in the execution node. If the transaction pool of the execution node determines that the first transaction identifier exists, the first transaction is discarded; if the transaction pool of the execution node determines that the first transaction does not exist, then the first transaction identifier continues to be processed through the second processing filter. Deduplication filtering.
  • the second processing filter when the second processing filter determines that the first transaction identifier exists, will also deduplicate the first transaction identifier a second time through the ledger database, thereby improving the efficiency of deduplication filtering in the execution node. accuracy.
  • FIG 11 is a flowchart of a transaction processing method according to an exemplary embodiment.
  • the above transaction processing method may include the following steps.
  • S1104 When it is determined that the first block satisfies the first expansion condition, determine the first node among the nodes of the blockchain to perform filter expansion according to the first expansion condition.
  • the capacity of the first expansion filter is greater than the capacity of the first processing filter in the execution node, and the first expansion filter is generated by the first node based on the transactions that have been uploaded in the blockchain.
  • S1114 Determine the second node to perform filter expansion among the nodes in the blockchain according to the second expansion condition.
  • the second expansion condition may be the number of blocks, the number of transactions, etc. set according to actual needs. For example, it may be the number of blocks or the number of transactions set according to the capacity of the filter. This disclosure There are no restrictions on this. It can be understood that the greater the capacity of the filter, the greater the number of blocks set in the second expansion condition (that is, under the same error rate, the transactions (or blocks) that a filter with a large capacity can process the bigger).
  • the first expansion condition and the second expansion condition may be different.
  • the number of blocks and the number of transactions set in the second expansion condition are greater than the number of blocks and the number of transactions set in the first expansion condition.
  • the capacity of the filter corresponding to the second expansion condition is also greater than the capacity of the filter corresponding to the first expansion condition.
  • the second expansion filter is generated by the second node based on the transactions that have been uploaded to the blockchain.
  • the transactions that have been uploaded to the blockchain include the transactions in the first block.
  • the technical solution improved in this embodiment can promptly correct the problem when the error rate of the filter in the second process is greater than a certain threshold (or the number of blocks or transactions in the blockchain is greater than a certain threshold).
  • the filter is expanded to improve the accuracy of the filter.
  • the first node for constructing the first expansion filter according to the first expansion condition may be the local node.
  • Public execution nodes That is to say, while performing the construction of the first expansion filter, the first node also performs the construction and use of the filter in the first process.
  • Figure 12 is a flow chart of a method for building an expansion filter according to an exemplary embodiment.
  • the above expansion filter construction method may include the following steps.
  • the first node can be a node with better performance and more computing resources in the blockchain.
  • nodes with better performance and more computing resources in the blockchain can be allowed to build the first expansion filter in the background. This will not affect the business in the first node, nor will it be affected by the first expansion filter. The construction affects the business in other nodes.
  • S1206 Load the third block into the first expansion filter, so that the first node builds the first expansion filter while building the first in-process filter.
  • the first node it is not only necessary to perform the construction of the filter in the first process but also to construct the first expansion filter in the background (that is, in the memory). After completing the construction of the first expansion filter, it will not affect the business (which can be the execution efficiency and execution accuracy of the business) in the nodes in the blockchain.
  • the second node that performs the construction of the second expansion filter according to the second expansion condition may be the execution node in the present disclosure. That is to say, while performing the construction of the second expansion filter, the second node also performs the construction and use of the filter in the second process.
  • Figure 14 is a flow chart of a method for building an expansion filter according to an exemplary embodiment.
  • the above expansion filter construction method may include the following steps.
  • the second expansion filter is constructed in the background (that is, in the memory). After completing the construction of the second expansion filter, it will not affect the business (which can be the execution efficiency and execution accuracy of the business) in the nodes in the blockchain.
  • some nodes have a lot of computing resources, so they not only have to perform the construction of the filter in the first process, but also build the first expansion filter and the second expansion filter in the background (that is, in the memory) (as shown in the figure) shown in 16). Therefore, the first node and the second node may be the same node, and this disclosure is not limited thereto.
  • Figure 17 is a flowchart of a method for modifying capacity expansion conditions according to an exemplary embodiment.
  • the above-mentioned capacity expansion condition modification method may include the following steps.
  • the actual error rate of the filter in the first process can be determined based on the blocks or transactions that have been uploaded in the blockchain. This disclosure does not limit the method of determining the above-mentioned actual error rate. Those skilled in the art can be based on actual Determine actual needs.
  • those skilled in the art can preset a target error rate, where the target error rate corresponds to the first expansion condition.
  • the first expansion condition when it is determined that the actual error rate of the filter in the first process when the Nth block is uploaded is lower than the target error rate or higher than the target error rate, the first expansion condition may be modified, N is a positive integer greater than 1.
  • the target error rate of the filter in the first processing when setting the first expansion condition, it is considered that the target error rate of the filter in the first processing will reach a certain threshold when the Mth block is uploaded to the chain, and it should be before the filtering in the first processing in the Kth block.
  • Expand capacity In actual operation, it was found that when the Mth block was uploaded to the chain, the target error rate of the filter in the first process was much smaller than the target error rate. Then it can be considered that the filter in the first process can continue to be used, and there is no need to worry. To expand the capacity, the first expansion condition needs to be modified.
  • the target error rate of the filter in the first process is greater than the target error rate, then it can be considered that the filter in the first process may not be able to continue to be used, and it is necessary If the capacity is expanded in time, the first expansion condition also needs to be modified.
  • the technical solution provided by this embodiment can modify the first expansion condition through a transaction on-chain, and can facilitate the modification of the first expansion condition based on the actual error rate of the filter in the first processing, which is flexible and effective.
  • Figure 18 is a schematic diagram of a deduplication filtering method according to an exemplary embodiment.
  • the above deduplication filtering method may include the following steps.
  • S1816 is executed to summarize the Bloom filter judgment results in the process.
  • S1818 is executed to judge the transaction object through the ledger database.
  • S1820 is executed to add the transaction object to the transaction pool.
  • the technical solution provided by this embodiment can accurately deduplicate and filter the transactions to be uploaded in the blockchain.
  • Figure 19 is a schematic diagram of a deduplication filtering method according to an exemplary embodiment.
  • the above deduplication filtering method may include the following steps.
  • S1906 is executed to obtain the processing filter from the memory.
  • S1910 is executed to obtain the in-process filter from the memory, and store the first block in the in-process filter after consensus.
  • S1912 Determine the expansion node in the target blockchain that performs filter expansion according to the target expansion conditions.
  • an expanded filter is obtained from the first node of the blockchain as the execution node Processing filter to deduplicate and filter subsequent transactions on the chain.
  • the execution node can realize the expansion of the filter in time when the first block meets the expansion conditions, and continuing to perform deduplication filtering based on the expanded filter can improve the deduplication accuracy of the execution node;
  • the expansion filter is built by other nodes in the blockchain, does not occupy the resources of the execution node, and will not have any impact on the execution node's business (such as deduplication filtering business), which is suitable for those with lower performance ( For example, for nodes with fewer cores), it can improve the accuracy of deduplication without affecting the node's own business; in addition, the filter can also be stored on the chain to trace evil behaviors in order to increase the number of nodes. The cost of doing evil, thereby reducing the evil behavior of nodes.
  • Figure 20 is a flow chart of a method for reloading a filter according to an exemplary embodiment.
  • This embodiment provides a method for nodes to reload filters.
  • the above method of reloading a filter may include the following steps.
  • S2010 is executed to create an empty Bloom filter (NBF).
  • NBF Bloom filter
  • BC is the 0th block
  • execute S2020 traverse the transactions in BC, and load them to NBF after calculation.
  • S2022 is executed in a loop to add NBF to the in-memory filtering component so that the transactions to be uploaded to the chain can be deduplicated and filtered through the filtering component.
  • the node can load the filter into the memory (filtering component) after starting.
  • embodiments of the present disclosure also provide a transaction processing device, such as the following embodiments. Since the problem-solving principle of this device embodiment is similar to that of the above-mentioned method embodiment, the implementation of this device embodiment can refer to the implementation of the above-mentioned method embodiment, and repeated details will not be repeated.
  • FIG 21 is a block diagram of a transaction processing device according to an exemplary embodiment.
  • the transaction processing device 2100 provided by the embodiment of the present disclosure may include: a first block acquisition module 2101, a first node determination module 2102, a first expansion filter determination module 2103, and a first block loading module 2104.
  • the transaction processing device 2100 may be an execution node on the blockchain.
  • the first block acquisition module 2101 can be used to acquire the first block to be uploaded in the blockchain; the first node determination module 2102 can be used to determine that the first block meets the first expansion condition. Next, determine the first node to perform filter expansion among the nodes of the blockchain according to the first expansion condition; the first expansion filter determination module 2103 can be used to obtain the first expansion filter from the first node, and the first expansion filter The capacity of the filter is greater than the capacity of the first processing filter in the execution node.
  • the first expansion filter is generated by the first node based on the transactions that have been uploaded in the blockchain; the first block loading module 2104 can be used to Load the transactions in the first block to the first expansion filter, and use the first expansion filter as the second in-process filter, so that the transactions to be uploaded to the blockchain are processed through the second in-process filter. Deduplication filtering.
  • first block acquisition module 2101 corresponds to S402 to S408 in the method embodiment.
  • first node determination module 2102 corresponds to S402 to S408 in the method embodiment.
  • the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above method embodiments.
  • the above-mentioned modules, as part of the device can be executed in a computer system such as a set of computer-executable instructions.
  • the transaction processing further includes: a filter acquisition module, a consensus module and a storage module in the first processing.
  • the first processing filter acquisition module can be used to obtain the first processing filter from the memory of the execution node before using the first expansion filter as the second processing filter;
  • the consensus module can be used to determine When the first block meets the first expansion condition, the first filter in processing is consensused;
  • the storage module can be used to store the first filter in processing in the first block after the consensus is passed.
  • the transaction processing device may further include: a first in-process filter determination module and a first block loading module.
  • the first in-process filter determination module can be used to obtain the first in-process filter from the memory of the execution node when it is determined that the first block does not meet the first expansion condition; the first block loading module can be used Loading the transactions in the first block to the first processing filter, so as to deduplicate and filter the transactions to be uploaded to the blockchain through the first processing filter.
  • the first node includes a first execution node; wherein the first expansion filter determination module 2103 may include: a first target expansion filter acquisition sub-module, a security detection sub-module, a first expansion filter determination sub-module module.
  • the first target expansion filter acquisition sub-module can be used to obtain the first target expansion filter from the first execution node; the security detection sub-module can be used to perform security detection on the first target expansion filter; the first expansion filter
  • the determining sub-module may be configured to use the first target capacity expansion filter as the first capacity expansion filter when it is determined that the safety detection of the first target capacity expansion filter passes.
  • the first node also includes a second execution node; wherein the first expansion filter determination module 2103 It may include: a second target expansion filter acquisition sub-module, a second security detection sub-module, a second target expansion filter conversion module, a candidate expansion filter generation sub-module and a candidate expansion filter conversion sub-module.
  • the second target expansion filter acquisition sub-module can be used to obtain the second target expansion filter from the second execution node when it is determined that the first target expansion filter fails the security test;
  • the second safety detection sub-module can Used to perform safety detection on the second target expansion filter;
  • the second target expansion filter conversion module can be used to use the second target expansion filter as the first expansion filter when it is determined that the second target expansion filter passes the safety test.
  • the candidate expansion filter generation sub-module can be used to construct a candidate expansion filter based on the transactions on the blockchain when it is determined that the second target expansion filter fails the security test.
  • the candidate expansion filter's The capacity is equal to the capacity of the first target expansion filter;
  • the candidate expansion filter conversion sub-module can be used to use the candidate expansion filter as the first expansion filter.
  • the security detection sub-module may include: a candidate expansion filter building unit and a security detection unit.
  • the candidate expansion filter construction unit can be used to construct a candidate expansion filter based on the transactions on the blockchain, and the capacity of the candidate expansion filter is equal to the capacity of the first target expansion filter;
  • the security detection unit can be used to construct a candidate expansion filter based on The candidate expansion filter performs security detection on the first target expansion filter.
  • the security detection sub-module may include: an on-chain transaction acquisition unit, a virtual transaction construction unit and a second security detection unit.
  • the on-chain transaction acquisition unit can be used to obtain at least one on-chain transaction from the blockchain;
  • the virtual transaction construction unit can be used to randomly construct at least one virtual transaction;
  • the second security detection unit can be used to obtain at least one on-chain transaction based on at least one on-chain transaction.
  • On-chain transactions and at least one virtual transaction perform security checks on the first target expansion filter.
  • the transaction processing device may further include: a transaction acquisition sub-module and a first expansion filter construction sub-module.
  • the transaction acquisition sub-module can be used to obtain the transactions on the blockchain without obtaining the first expansion filter from the first node; the first expansion filter construction sub-module can be used to obtain the first expansion filter according to the area.
  • the transactions on the blockchain build the first expansion filter.
  • the transaction processing device may further include: a first transaction acquisition module, a deduplication filtering module, and a first judgment module.
  • the first transaction acquisition module can be used to obtain the first transaction, and the first transaction includes the first transaction identifier;
  • the deduplication filtering module can be used to deduplicate and filter the first transaction identifier through the second processing filter;
  • the first The judgment module may be used to add the first transaction to the transaction pool of the blockchain when the filter judges in the second process that the first transaction identifier does not exist on the blockchain.
  • the transaction processing device may further include: a second judgment module, a third module and a fourth judgment module.
  • the second judgment module can be used to make a deduplication judgment on the first transaction identifier through the ledger database of the blockchain when the filter determines that there is a first transaction identifier on the blockchain in the second process;
  • the third judgment The module can be used to add the first transaction identifier to the transaction pool of the blockchain when it is determined through the ledger database that there is no first transaction identifier on the blockchain;
  • the fourth judgment module can be used to determine when the first transaction identifier does not exist on the blockchain through the ledger database.
  • discard First transaction when the first transaction identifier exists, discard First transaction.
  • the transaction processing device may also include: a second block acquisition module, a second processing filter consensus module, a second node determination module, a second expansion filter acquisition module, and a second expansion filter loading module. .
  • the second block acquisition module can be used to obtain the second block to be uploaded to the chain; the filter consensus module in the second process can be used to add the second block to the chain when it is determined that the second block meets the second expansion condition.
  • the filter during processing performs consensus and is stored in the second block after the consensus is passed.
  • the first expansion condition and the second expansion condition are different;
  • the second node determination module can be used to determine the node in the blockchain according to the second expansion condition. Determine the second node that performs filter expansion;
  • the second expansion filter acquisition module can be used to obtain the second expansion filter from the second node.
  • the capacity of the second expansion filter is greater than the first expansion filter.
  • the second expansion filter The filter is generated by the second node based on the transactions that have been uploaded in the blockchain.
  • the transactions that have been uploaded in the blockchain include transactions in the first block; the second expansion filter loading module can be used to convert the second block into The transactions in the block are loaded into the second expansion filter, and the second expansion filter is used as the third in-process filter, so that the transactions to be uploaded to the blockchain are deduplicated and filtered through the third in-process filter.
  • the first node is an execution node; the transaction processing device may further include: a third block acquisition module and a simultaneous construction module.
  • the third block acquisition module can be used for the first node to acquire the third block to be uploaded before acquiring the first expansion filter from the first node; at the same time, the construction module can be used to determine that the third block does not satisfy In the case of the first expansion condition, while loading the third block to the first processing filter, the third block is also loaded to the first expansion filter, so that the first node can filter in the first processing
  • the first expansion filter is constructed at the same time as the filter.
  • the execution node is a second node that performs filter expansion according to the second expansion condition; the transaction processing device may further include: a fourth block acquisition module and a simultaneous construction module.
  • the fourth block acquisition module can be used to acquire the fourth block to be uploaded after using the first expansion filter as the second in-process filter; at the same time, the construction module can be used to determine the fourth block after determining the fourth block. If a block satisfies the first expansion condition but does not meet the second expansion condition, load the fourth block to the second in-process filter; load the fourth block to the A second expansion filter, such that the second expansion filter is constructed simultaneously with the construction of the second in-process filter.
  • the transaction processing device may further include: an expansion condition modification module, which is used to:
  • the first expansion condition is modified according to the content in the second transaction.
  • modules and/or sub-modules and/or units described in the embodiments of this application can be implemented in software or hardware.
  • the described modules and/or sub-modules and/or units may also be provided in the processor. Wherein, the names of these modules and/or sub-modules and/or units do not under certain circumstances constitute a reference to the module and/or Qualifications for submodules and/or units themselves.
  • each block in the flowchart or block diagrams may represent a module, segment, or portion of code that contains one or more logic functions that implement the specified executable instructions.
  • the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown one after another may actually execute substantially in parallel, or they may sometimes execute in the reverse order, depending on the functionality involved.
  • each block in the block diagram or flowchart illustration, and combinations of blocks in the block diagram or flowchart illustration can be implemented by special purpose hardware-based systems that perform the specified functions or operations, or may be implemented by special purpose hardware-based systems that perform the specified functions or operations. Achieved by a combination of specialized hardware and computer instructions.
  • FIG. 22 shows a schematic structural diagram of an electronic device suitable for implementing embodiments of the present disclosure. It should be noted that the electronic device 2200 shown in FIG. 22 is only an example, and should not bring any limitations to the functions and scope of use of the embodiments of the present disclosure.
  • the electronic device 2200 includes a central processing unit (CPU) 2211 that can operate according to a program stored in a read-only memory (ROM) 2212 or loaded from a storage portion 2218 into a random access memory (RAM) 2213 And perform various appropriate actions and processing.
  • CPU 2211, ROM 2212 and RAM 2213 are connected to each other through bus 2214.
  • An input/output (I/O) interface 2215 is also connected to bus 2214.
  • the following components are connected to the I/O interface 2215: an input section 2216 including a keyboard, a mouse, etc.; an output section 2217 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., speakers, etc.; and a storage section 2218 including a hard disk, etc. ; and a communication section 2219 including a network interface card such as a LAN card, a modem, etc.
  • the communication section 2219 performs communication processing via a network such as the Internet.
  • Driver 2210 is also connected to I/O interface 2215 as needed.
  • Removable media 2211 such as magnetic disks, optical disks, magneto-optical disks, semiconductor memories, etc., are installed on the drive 2210 as needed, so that computer programs read therefrom are installed into the storage portion 2218 as needed.
  • embodiments of the present disclosure include a computer program product including a computer program carried on a computer-readable storage medium, the computer program containing program code for performing the method illustrated in the flowchart.
  • the computer program may be downloaded and installed from the network via communication portion 2219, and/or installed from removable media 2211.
  • CPU central processing unit
  • the computer-readable storage medium shown in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two.
  • the computer-readable storage medium may be, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination thereof. More specific examples of computer readable storage media may include, but are not limited to: electrical connections having one or more conductors. Connector, portable computer disk, hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), Optical storage device, magnetic storage device, or any suitable combination of the above.
  • a computer-readable storage medium may be any tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device.
  • the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, in which computer-readable program code is carried. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above.
  • a computer-readable signal medium may also be any computer-readable storage medium other than a computer-readable storage medium that may be sent, propagated, or transmitted for use by or in connection with an instruction execution system, apparatus, or device program of.
  • Program code embodied on a computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
  • embodiments of the present application also provide a storage medium, the storage medium is used to store a computer program, and the computer program is used to execute the method provided in the above embodiments.
  • Embodiments of the present application also provide a computer program product including a computer program, which when run on a computer causes the computer to execute the method provided in the above embodiments.
  • the example embodiments described here can be implemented by software, or can be implemented by software combined with necessary hardware. Therefore, the technical solution of the embodiment of the present disclosure can be embodied in the form of a software product.
  • the software product can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) and includes a number of instructions.
  • a computing device which can be a personal computer, server, mobile terminal, or smart device, etc.
  • the method according to the embodiment of the present disclosure such as Figure 4, Figure 6, Figure 8 to Figure 12, Figure 14 or Figure 17 ⁇
  • Figure 4 Figure 6
  • Figure 12 Figure 14 or Figure 17

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Computing Systems (AREA)
  • Quality & Reliability (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Computational Linguistics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本公开提供一种交易处理方法、装置以及电子设备和计算机可读存储介质,涉及计算机技术技术领域。该交易处理方法由区块链上的执行节点执行,交易处理方法包括:获取待上链的第一区块;在确定第一区块满足第一扩容条件的情况下,根据第一扩容条件在区块链的节点中确定执行过滤器扩容的第一节点;从第一节点处获取第一扩容过滤器,第一扩容过滤器的容量大于执行节点中的第一处理中过滤器的容量,第一扩容过滤器是第一节点根据区块链中已上链的交易生成的;将第一区块中的交易加载至第一扩容过滤器,并将第一扩容过滤器作为第二处理中过滤器,以便通过扩容后第二处理中过滤器对区块链的待上链的交易进行去重过滤。

Description

交易处理方法、装置、设备、存储介质和程序产品
本申请要求于2022年07月19日提交中国专利局、申请号为202210848919.0、申请名称为“交易处理方法、装置、电子设备和计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本公开涉及计算机与互联网技术领域,尤其涉及交易处理。
背景技术
在区块链***中,同一笔交易是不允许重复的,重复的交易会引起“双花”的问题,通俗来讲就是一笔钱花了两次,这在区块链中是绝对不被允许的。因此,所有的区块链***都会对交易进行一个去重的操作,保证上链的每笔交易间是不存在重复的。
所谓的交易去重就是判断交易是否已经在当前节点的账本中存在。
目前业内常用的方式是采用过滤器(如布隆过滤器)进行交易过滤,但是该过滤器有一个缺点,它会随着交易数量的增加误判率越来越高,当交易数量到达一定的规模的时候,过滤器的误判率会非常高,这个时候大部分交易都会判断错误,这样就失去了过滤器的意义。
因此,如何提高过滤器的去重过滤的准确度已成为亟待解决的问题。
发明内容
本公开的目的在于提供一种交易处理方法、装置、电子设备以及计算机可读存储介质和程序产品,可以提高节点的去重准确度。
本公开的其他特性和优点将通过下面的详细描述变得显然,或部分地通过本公开的实践而习得。
本公开实施例提供了一种交易处理方法,包括:获取所述区块链中待上链的第一区块;在确定所述第一区块满足第一扩容条件的情况下,根据所述第一扩容条件在所述区块链的节点中确定执行过滤器扩容的第一节点;
从所述第一节点处获取第一扩容过滤器,所述第一扩容过滤器的容量大于所述执行节点中的第一处理中过滤器的容量,所述第一扩容过滤器是所述第一节点根据所述区块链中已上链的交易生成的;将所述第一区块中的交易加载至所述第一扩容过滤器,并将所述第一扩容过滤器作为第二处理中过滤器,以便通过第二处理中过滤器对所述区块链的待上链的交易进行去重过滤。
本公开实施例提供了一种交易处理装置,包括:第一区块获取模块、第一节点确定模块、第一扩容过滤器确定模块和第一区块加载模块。
其中,所述第一区块获取模块用于获取所述区块链中待上链的第一区块;所述第一节点确定模块用于在确定所述第一区块满足第一扩容条件的情况下,根据所述第一扩容条件在所述区块链的节点中确定执行过滤器扩容的第一节点;所述第一扩容过滤器确定模块用于从所述第一节点处获取第一扩容过滤器,所述第一扩容过滤器的容量大于所述执行节点中的第一处理中过滤器的容量,所述第一扩容过滤器是所述第一节点根据所述区块链中已上链的交易生成的;所述第一区块加载模块用于将所述第一区块中的交易加载至所述第一 扩容过滤器,并将所述第一扩容过滤器作为第二处理中过滤器,以便通过第二处理中过滤器对所述区块链的待上链的交易进行去重过滤。
本公开实施例提出一种电子设备,该电子设备包括:一个或多个处理器;存储装置,用于存储一个或多个计算机程序,当所述一个或多个计算机程序被所述一个或多个处理器执行,使得所述一个或多个处理器实现上述任一项所述的交易处理方法。
本公开实施例提出一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上述任一项所述的交易处理方法。
本公开实施例提出一种包括计算机程序的计算机程序产品,当其在计算机上运行时,使得该计算机设备执行上述交易处理方法。
本公开实施例提供的交易处理方法、装置及电子设备和计算机可读存储介质,一方面执行节点可以在第一区块满足扩容条件时,及时地实现过滤器的扩容,根据该已扩容过滤器继续进行去重过滤能够提高执行节点的去重准确率;另一方面,该扩容过滤器是由区块链中的其他节点构建的,不用占用执行节点的资源,不会对执行节点的业务(例如去重过滤业务)产生任何影响,这对于那些性能较低(例如核数较少)的节点来说既提高了去重准去率又不会对节点自身的业务产生影响。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性的,并不能限制本公开。
附图说明
图1A是本申请实施例提供的一种交易处理***的架构示意图;
图1B是本申请实施例提供的一种区块链的结构示意图;
图1C是本申请实施例提供的一种产生新区块的过程示意图;
图2是根据相关技术示出的区块链去重过滤的示意图;
图3是根据相关技术示出的一种去重过滤方法的流程图;
图4是根据一示例性实施例示出的一种交易处理方法的流程图;
图5是根据一示例性实施例示出的一种交易处理方法的流程图;
图6是根据一示例性实施例示出的一种过滤组件示意图;
图7是根据一示例性实施例示出的一种区块链示意图;
图8是根据一示例性实施例示出的一种交易处理方法的流程图;
图9是根据一示例性实施例示出的一种第一扩容过滤器确定方法的流程图;
图10是根据一示例性实施例示出的一种去重过滤确定方法的流程图;
图11是根据一示例性实施例示出的一种交易处理方法的流程图;
图12是根据一示例性实施例示出的一种扩容过滤器构建方法的流程图;
图13是根据一示例性实施例示出的一种过滤组件的示意图;
图14是根据一示例性实施例示出的一种扩容过滤器构建方法的流程图;
图15是根据一示例性实施例示出的一种过滤组件的示意图;
图16是根据一示例性实施例示出的一种过滤组件的示意图;
图17是根据一示例性实施例示出的一种扩容条件修改方法的流程图;
图18是根据一示例性实施例示出的一种去重过滤方法的示意图;
图19是根据一示例性实施例示出的一种去重过滤方法的示意图;
图20是根据一示例性实施例示出的一种重新加载过滤器的方法流程图;
图21是根据一示例性实施例示出的一种交易处理装置的框图;
图22示出了适于用来实现本公开实施例的的电子设备的结构示意图。
具体实施方式
现在将参考附图更全面地描述示例实施例。然而,示例实施例能够以多种形式实施,且不应被理解为限于在此阐述的实施例;相反,提供这些实施例使得本公开将全面和完整,并将示例实施例的构思全面地传达给本领域的技术人员。在图中相同的附图标记表示相同或类似的部分,因而将省略对它们的重复描述。
本公开所描述的特征、结构或特性可以以任何合适的方式结合在一个或更多实施方式中。在下面的描述中,提供许多具体细节从而给出对本公开的实施方式的充分理解。然而,本领域技术人员将意识到,可以实践本公开的技术方案而省略特定细节中的一个或更多,或者可以采用其它的方法、组元、装置、步骤等。在其它情况下,不详细示出或描述公知方法、装置、实现或者操作以避免模糊本公开的各方面。
附图仅为本公开的示意性图解,图中相同的附图标记表示相同或类似的部分,因而将省略对它们的重复描述。附图中所示的一些方框图不一定必须与物理或逻辑上独立的实体相对应。可以采用软件形式来实现这些功能实体,或在一个或多个硬件模块或集成电路中实现这些功能实体,或在不同网络、处理器装置、微控制器装置的至少一个的组合中实现这些功能实体。
附图中所示的流程图仅是示例性说明,不是必须包括所有的内容和步骤,也不是必须按所描述的顺序执行。例如,有的步骤还可以分解,而有的步骤可以合并或部分合并,因此实际执行的顺序有可能根据实际情况改变。
在本申请的描述中,除非另有说明,“/”表示“或”的意思,例如,A/B可以表示A或B。本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。此外,“至少一个”是指一个或多个,“多个”是指两个或两个以上。“第一”、“第二”等字样并不对数量和执行次序进行限定,并且“第一”、“第二”等字样也并不限定一定不同;用语“包含”、“包括”和“具有”用以表示开放式的包括在内的意思并且是指除了列出的要素/组成部分/等之外还可存在另外的要素/组成部分/等;
为了能够更清楚地理解本申请的上述目的、特征和优点,下面结合附图和具体实施方式对本申请进行进一步的详细描述,需要说明的是,在不冲突的情况下,本申请的实施例及实施例中的特征可以相互组合。
针对目前区块链中的过滤器的去重准确率低的问题,本申请实施例提供了一种交易处理方法,可以在第一区块满足扩容条件的情况下及时从其他节点处获取已扩容过滤器,以便在提高过滤器的去重准确率的同时减少对执行节点的资源(内存资源或磁盘资源)占用。
请参见图1A,是本申请实施例提供的一种交易处理***的架构示意图,该交易处理***包括区块链网络10和终端设备20,其中:区块链网络10是指用于进行节点与节点之间数 据共享的网络,区块链网络中可以包括多个节点101。每个节点101在进行正常工作可以接收到输入信息,并基于接收到的输入信息维护区块链网络内的共享数据(即区块链)。为了保证区块链网络内的信息互通,每个节点之间可以存在信息连接,任意两个节点之间可以实现点对点(Peer To Peer,P2P)通信,具体可以通过有线通信链路或无线通信链路进行P2P通信。例如,当区块链网络中的任意节点接收到输入信息时,其他节点便根据共识算法获取该输入信息,将该输入信息作为共享数据中的数据进行存储,使得区块链网络中全部节点上存储的数据均一致。
终端设备20可以接入该区块链网络,并可以与区块链网络中的节点进行通信,例如,向节点提交待上链的交易,从节点获取数据,等等。其中,终端设备20具体可以是智能手机、平板电脑、笔记本电脑、台式电脑、车载智能终端等,本申请实施例不做限定。
需要说明的是,图1A中所示的节点的数目仅仅是示意性的,根据署任意数目的节点。
其中,对于区块链网络中的每个节点,均具有与其对应的节点标识,而且区块链网络中的每个节点均可以存储有区块链网络中其他节点的节点标识,以便后续根据其他节点的节点标识,将生成的区块广播至区块链网络中的其他节点。每个节点中可维护一个如下表所示的节点标识列表,将节点名称和节点标识对应存储至该节点标识列表中。其中,节点标识可为互联网协议(Internet Protocol,IP)地址以及其他任一种能够用于标识该节点的信息,例如IP地址。
表1
其中,区块链网络中的每个节点均存储一条相同的区块链。区块链由多个区块组实际需要,可以部成,参见图1B,区块链由多个区块组成,创始块中包括区块头和区块主体,区块头中存储有输入信息特征值、版本号、时间戳和难度值,区块主体中存储有输入信息;创始块的下一区块以创始块为父区块,下一区块中同样包括区块头和区块主体,区块头中存储有当前区块的输入信息特征值、父区块的区块头特征值、版本号、时间戳和难度值,并以此类推,使得区块链中每个区块中存储的区块数据均与父区块中存储的区块数据存在关联,保证了区块中输入信息的安全性。
其中,在生成区块链中的各个区块时,参见图1C,区块链所在的节点在接收到输入信息时,对输入信息进行校验,完成校验后,将输入信息存储至内存池中,并更新其用于记录输入信息的哈希树;之后,将更新时间戳更新为接收到输入信息的时间,并尝试不同的随机数,多次进行特征值计算,使得计算得到的特征值可以满足下述公式:
SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET。
其中,SHA256为计算特征值所用的特征值算法;version(版本号)为区块链中相关区块协议的版本信息;prev_hash为当前区块的父区块的区块头特征值;merkle_root为输入信息 的特征值;ntime为更新时间戳的更新时间;nbits为当前难度,在一段时间内为定值,并在超出固定时间段后再次进行确定;x为随机数;TARGET为特征值阈值,该特征值阈值可以根据nbits确定得到。
这样,当计算得到满足上述公式的随机数时,便可将信息对应存储,生成区块头和区块主体,得到当前区块。随后,区块链所在节点根据区块链网络中其他节点的节点标识,将新生成的区块分别发送给其所在的区块链网络中的其他节点,由其他节点对新生成的区块进行校验,并在完成校验后将新生成的区块添加至其存储的区块链中。
其中,区块链网络的节点上可以运行智能合约,智能合约是用于在满足一定条件时而执行的代码实现,开发人员可以通过编程语言定义合约逻辑,发布到区块链上(智能合约注册),根据合约条款的逻辑,调用密钥或者其他的事件触发执行,完成合约逻辑,同时还提供对智能合约升级、注销的功能。
在一些可行的实施方式中,区块链网络的某一节点101可以当接收到终端设备20提交的目标交易时,获取所述目标交易的摘要信息,并利用N个布隆过滤器(Bloom Filter)从已处理交易对应的摘要信息中查询目标交易的摘要信息,N为大于或等于1的整数,若查询到目标交易的摘要信息,则确定目标交易为已处理交易,并拒绝将目标交易添加到交易池中,可以利用布隆过滤器高效、准确地检查提交的交易是否在账本中已经出现过,从而有效避免重复交易。
图2是根据相关技术示出的区块链去重过滤的示意图。
如图2所示,相关技术中的区块链去重过滤过程的核心是先通过滤器(如布隆过滤器或者布谷鸟过滤器)对交易池中的交易进行重复判断,如果判断该交易存在的话,则再通过数据库进行二次判断,详细的处理流程如图3所示。
图3是根据相关技术示出的一种去重过滤方法的流程图。
参考图3,上述去重过滤方法可以包括以下步骤。
S302,获取交易对象。
S304,获取交易中的TxID(交易唯一key)。
S306,调用过滤组件,以便进行交易去重判断。
S308,通过过滤组件中的过滤器对交易对象进行去重判断。
在过滤器判断不存在交易对象时,执行S310,将交易对象放入交易池。
在过滤器判断存在交易对象时,执行S312,通过区块链的账本数据库对交易对象进行去重判断。
其中,上述账本数据库可以指的是区块链上的账本数据。
在账本数据库判断不存在交易对象时,执行S310。
在账本数据库判断不存在交易对象时,执行S314,丢弃该交易对象。
目前业内常用的方式是采用过滤器结合数据库进行过滤,但过滤器对交易重复的判断存在假阳性的情况。也就是说如果过滤器认为交易不存在(阴性)交易重复则一定不存在,若认为存在(阳性)交易重复则不一定,可能存在也可能不存在交易重复,需要进行进一步的判断(数据库判断)。
因此,过滤器自身存在有一个缺点,它会随着交易数量的增加误判率越来越高,当交易数量到达一定的规模的时候,过滤器的误判率会非常高,这个时候大部分交易都会判断阳性,这样就失去了过滤器的意义,也就是导致了判断击穿,会直接访问数据库,对数据库造成巨大的压力。
为了解决上述技术问题,在图1A~图1C示出的***架构下,本公开实施例中提供了一种交易处理方法,该方法可以由任意区块链中的任一节点执行,作为执行主体的该节点可以是任意具备计算处理能力的电子设备,为了便于说明,在本实施例中,将该节点记为执行节点。该执行节点和后续提及的第一节点、第二节点均为处于同一个区块链中的节点。
图4是根据一示例性实施例示出的一种交易处理方法的流程图。
参照图4,本公开实施例提供的交易处理方法可以包括以下步骤。
S402,获取区块链中待上链的第一区块。
其中,第一区块可以是来自执行节点的交易池但是还未上链的区块。
S404,在确定第一区块满足第一扩容条件的情况下,根据第一扩容条件在区块链的节点中确定执行过滤器扩容的第一节点。
其中,第一扩容条件可以包括根据实际需求设置的区块的个数、交易的个数等,例如可以是根据过滤器的容量大小设置的区块的个数或者交易的个数等,本公开对此不做限制。可以理解的是,过滤器的容量越大,第一扩容条件中设置的区块的个数越多(即在相同错误率的情况下,容量大的过滤器可以处理的交易(或者区块)数量越大)。
上述第一扩容条件可以具体为:当区块链中的区块个数大于目标区块个数阈值时(或者交易个数大于目标交易个数时),按照目标容量进行扩容处理。本领域技术人员可以根据实际需求设置上述目标区块个数阈值或者目标交易个数或者目标容量,本公开对此不做限制。
S406,从第一节点处获取第一扩容过滤器。
第一扩容过滤器的容量大于执行节点中的第一处理中过滤器的容量,第一扩容过滤器是第一节点根据区块链中已上链的交易生成的。
上述第一扩容过滤器或第一处理中过滤器可以是布隆过滤器或者布谷鸟过滤器等任意一种可以进行去重过滤的过滤器,本公开对此不做限制。
其中,布隆过滤器可以是一种判断某个数据是否存在的数据结构,该结构占用内存空间小,但会存在一定的误判率,随着布隆过滤器中数据量越来越大,其误判率会越来越高。布隆过滤器的判断结果是假阳性,也就是说如果判断某个值不存在,则一定不存在,如果判断某个值存在则不一定存在。
在一些实施例中,上述第一处理中过滤器可以运行于执行节点的内存中,但本公开并不限制于此。
第一扩容过滤器可以由区块链中性能较好(例如核数多、内存大或磁盘空间大)的节点生成。具体由哪些节点构建第一扩容过滤器,区块链可以根据各个节点的性能进行确定。总之,性能越好的节点构建的扩容过滤器可以越多,性能不好的节点,可以完全不构建扩容过滤器,由此可以避免扩容过滤器的构建对节点的业务的影响。
S408,将第一区块中的交易加载至第一扩容过滤器,并将第一扩容过滤器作为第二处理中过滤器,以便通过第二处理中过滤器对区块链的待上链的交易进行去重过滤。
在一些实施例中,可以通过多种哈希算法对第一区块中的交易进行哈希计算,然后将计算结果加载至第一扩容过滤器。
在一些实施例中,上述第一扩容过滤器可以是布隆过滤器。布隆过滤器的核心实现是一个超大的位数组和几个哈希函数。在一些实施例中,可以假设位数组的长度为m,哈希函数的个数为k,m为大于1的整数,k为大于1的整数。
在一些实施例中,可通过如下实施例解释如何将第一区块中的交易加载至第一扩容过滤器:首先将第一扩容过滤器对应的位数组进行初始化,将里面每个位都设置位0。对于第一区块中的每一个交易,将交易依次通过k个哈希函数进行映射,每次映射都会产生一个哈希值,这个值对应位数组上面的一个点,然后将位数组对应的位置标记为1。
在一些实施例中,如果要查询W元素是否存在于对扩容过滤器的中的时候,同样的方法将W通过哈希映射到位数组上的k个点。如果k个点的其中有一个点不为1,则可以判断该元素一定不存在集合中。反之,如果k个点都为1,则该元素可能存在集合中。
在一些实施例中,执行节点可以使用第一扩容过滤器代替原有的第一处理中过滤器,以便执行节点通过该第一扩容过滤器对区块链中的待上链交易进行去重过滤。
在一些实施例中,在未从第一节点处获得第一扩容过滤器的情况下,可以获取区块链中已上链的交易;然后根据区块链中已上链的交易构建第一扩容过滤器,并将第一扩容过滤器作为第二处理中过滤器,以便通过第二处理中过滤器对区块链的待上链的交易进行去重过滤。
本实施例提供的技术方案,在第一区块满足第一扩容条件时(例如第一处理中过滤器的错误率达到某个阈值),则从区块链的第一节点中获取一已扩容的过滤器作为执行节点的处理中过滤器,以对后续上链的交易进行去重过滤。通过上述方法,一方面执行节点可以在第一区块满足扩容条件时,及时地实现过滤器的扩容,根据该已扩容过滤器继续进行去重过滤能够提高执行节点的去重准确率;另一方面,该扩容过滤器是由区块链中的其他节点构建的,不用占用执行节点的资源,不会对执行节点的业务(例如去重过滤业务)产生任何影响,这对于那些性能较低(例如核数较少)的节点来说即提高了去重准去率又不会对节点自身的业务产生影响。
图5是根据一示例性实施例示出的一种交易处理方法的流程图。
参考图5,上述交易处理方法可以包括以下步骤。
S502,获取区块链中待上链的第一区块。
S504,在确定第一区块满足第一扩容条件的情况下,根据第一扩容条件在区块链的节点中确定执行过滤器扩容的第一节点。
S506,从第一节点处获取第一扩容过滤器。
第一扩容过滤器的容量大于执行节点中的第一处理中过滤器的容量,第一扩容过滤器是第一节点根据区块链中已上链的交易生成的。
S508,在确定第一区块满足第一扩容条件的情况下,从执行节点的内存中获取第一处 理中过滤器。
在一些实施例中,执行节点可以从运行于内存的过滤组件中获取第一处理中过滤器。如图6所示,执行节点的内存中的过滤组件中可以包括一个处理中过滤器(例如第一处理中过滤器)和一账本数据库,该处理中过滤器是根据第0区块~当前已上链区块中的交易生成的,该账本数据库可以是根据区块链已上链的交易生成的。
其中,处理中过滤器(例如第一处理中过滤器)可以指的是目前正在对交易进行去重过滤的布隆过滤器,该布隆过滤器会随着交易写入账本而改变;账本数据库是一种本地节点存储账本的数据库。
在一些实施例中,当第一区块满足第一扩容条件时,可以认为第一处理中过滤器的错误率达到了某个阈值,不适合继续进行去重过滤操作。
S510,将第一处理中过滤器进行共识。
在一些实施例中,如果确定第一区块满足第一扩容条件(或者执行节点的第一处理中过滤器的错误率达到了某个阈值,进而确定该第一处理中过滤器不适合继续加载交易了),则将第一处理中过滤器在区块链中进行共识。
S512,在共识通过后将第一处理中过滤器存储在第一区块中。
在一些实施例中,可以通过以下方法将第一处理中过滤器进行上链存储:执行节点在区块链中发起将第一处理中过滤器上链的交易;区块链中的多个共识节点(该共识节点为区块链中的节点)对第一处理中过滤器进行共识处理(例如确定执行节点上传的第一处理中过滤器与自身生成的第一处理中过滤器是否一致,如果一致则共识通过);当共识通过的共识节点的个数超出目标阈值时则认为第一处理中过滤器共识通过;在第一处理中过滤器在区块链中共识通过的情况下,将第一处理中过滤器存储在交易池中的第一区块的区块体中;最后将交易池中的第一区块在区块链中上链落盘。
在一些实施例中,可在合适的实际对第一处理中过滤器和第二处理中过滤器等进行共识上链,以便进行追溯,增加节点或者客户端作恶成本,降低节点或者客户端的作恶行为。
上述实施例,可以在第一区块满足第一扩容条件的情况下将第一处理中过滤器进行共识上链并存储在第一区块中,以便后续进行追溯,增加节点作恶(恶意拒绝上链或者恶意上链)成本,提高区块链上链数据的真实性和可靠性。
图7是根据一示例性实施例示出的一种区块链的示意图。
如图7所示,在该区块链中部分区块(如第99个区块、第199个区块、第299个区块等)可以存储有过滤器,以便在发现存在节点或者客户端作恶时对作恶行为进行追溯。
S514,将第一区块中的交易加载至第一扩容过滤器,并将第一扩容过滤器作为第二处理中过滤器,以便通过第二处理中过滤器对区块链的待上链的交易进行去重过滤。
本实施例提出的技术方案,一方面可以通过将第一处理过滤器存储在区块中以加快启动时对过滤器的加载过程;另一方面可以对作恶行为进行追溯,以便增加节点作恶的成本,从而避免节点作恶。
图8是根据一示例性实施例示出的一种交易处理方法的流程图。
参考图8,上述交易处理方法可以包括以下步骤。
S802,获取区块链中待上链的第一区块。
S804,在确定第一区块满足第一扩容条件的情况下,根据第一扩容条件在区块链的节点中确定执行过滤器扩容的第一节点。
S806,从第一节点处获取第一扩容过滤器。
第一扩容过滤器的容量大于执行节点中的第一处理中过滤器的容量,第一扩容过滤器是第一节点根据区块链中已上链的交易生成的。
S808,将第一区块中的交易加载至第一扩容过滤器,并将第一扩容过滤器作为第二处理中过滤器,以便通过第二处理中过滤器对区块链的待上链的交易进行去重过滤。
S810,在确定第一区块不满足第一扩容条件的情况下,从执行节点的内存中获取第一处理中过滤器。
S812,将第一区块中的交易加载至第一处理中过滤器,以便通过第一处理中过滤器对区块链的待上链交易进行去重过滤。
本实施例提供的技术方案,在第一区块不满足第一扩容条件时将第一区块继续加载至执行节点中的处理中过滤器(即第一处理中过滤器的错误率未达到某个阈值)。通过上述方法,可在本地存储的第一处理中过滤器符合去重过滤条件时直接进行去重过滤,不再需要从其他节点获取新的过滤器,降低了区块链的数据交互次数,提升了区块链的上链效率。
在一些实施例中,区块链的多个节点中可以包括第一节点。该第一节点可以是区块链中设备性能好(如核数多、内存大、磁盘大或者计算能力强)的节点。
在一些实施例中,该第一节点也可以是一个或者多个。在一些实施例中,第一节点可以包括第一执行节点和第二执行节点。
下面将以第一执行节点和第二执行节点为例解释如何从第一节点中获取第一扩容过滤器。可以理解的是,第一节点还可以包括第三执行节点、第四执行节点……等,本领域技术人员可以将下述实施例提供的技术方案很容易扩展到第一节点还可以包括第三执行节点、第四执行节点……的情况中。
图9是根据一示例性实施例示出的一种第一扩容过滤器确定方法的流程图。
参考图9,上述第一扩容过滤器确定方法可以包括以下步骤。
S902,从第一执行节点获取第一目标扩容过滤器。
S904,对第一目标扩容过滤器进行安全检测。
为了确定第一执行节点构建的第一目标扩容过滤器是否是正确的,可以对第一执行节点提供的第一目标扩容过滤器进行安全检测。
在一些实施例中,可以通过以下方法对第一目标扩容过滤器进行安全检测:根据区块链中已上链的交易构建候选扩容过滤器,候选扩容过滤器的容量等于第一目标扩容过滤器的容量;根据候选扩容过滤器对第一目标扩容过滤器进行安全检测。
在一些实施例中,可以通过以下方法对第一目标扩容过滤器进行安全检测:从区块链中获取至少一个已上链交易;随机构建至少一个虚拟交易;根据至少一个已上链交易和至少一个虚拟交易对第一目标扩容过滤器进行安全检测。
S906,在确定第一目标扩容过滤器安全检测通过的情况下,将第一目标扩容过滤器作 为第一扩容过滤器。
在一些实施例中,在第一扩容过滤器通过安全检测的情况下,可以将第一扩容过滤器直接作为第一扩容过滤器。
S908,在确定第一目标扩容过滤器安全检测不通过的情况下,从第二执行节点获取第二目标扩容过滤器。
S910,对第二目标扩容过滤器进行安全检测。
S912,在确定第二目标扩容过滤器安全检测通过的情况下,将第二目标扩容过滤器作为第一扩容过滤器。
当然,如果第一节点还有第三执行节点、第四执行节点的话,那么还可以继续从第三执行节点或者第四执行节点获取扩容过滤器,以便获得第一扩容过滤器。
S914,在确定第二目标扩容过滤器安全检测不通过的情况下,根据区块链中已上链的交易构建候选扩容过滤器,候选扩容过滤器的容量等于第一目标扩容过滤器的容量。
S916,将候选扩容过滤器作为第一扩容过滤器。
上述实施例,一方面可以通过安全检测确定获取的第一扩容过滤器没有被恶意篡改,是真实有效的,从而提高去重过滤的准确性;另一方面,可以从多个第一节点中获取第一扩容过滤器,既提高了第一扩容过滤器的真实性,又能避免由执行节点自己构建第一扩容过滤器导致的去重过滤效率低下等问题。
在另外一些实施例中,第一节点可以包括多个执行节点,第一扩容过滤器可以在多个执行节点中共识,并在共识通过后再发给执行节点(如果共识不通过,则不发给执行节点);执行节点在接收到多个执行节点共识通过后的第一扩容过滤器后,会对接收到的第一扩容过滤器进行安全检测;并在安全检测通过后将第一扩容过滤器作为处理中过滤器对待上链的交易进行去重过滤。该方案可以保证第一扩容过滤器中记载的有且仅有所有的已上链交易,避免第一节点作恶,进而提高了区块链上链数据的去重过滤有效性。
图10是根据一示例性实施例示出的一种去重过滤确定方法的流程图。
参考图10,上述去重过滤方法可以包括以下步骤。
S1002,获取第一交易。
第一交易包括第一交易标识。
上述第一交易标识可以是图7中区块中的Tx01、Tx02、Tx03……等,本公开对此不做限制。
S1004,通过第二处理中过滤器对第一交易标识进行去重过滤。
在一些实施例中,在通过第二处理中过滤器对第一交易标识进行去重过滤之前,还需要通过执行节点中的交易池对第一交易标识进行去重过滤。如果执行节点的交易池确定第一交易标识存在的话,则抛弃该第一交易;如果执行节点的交易池确定第一交易不存在的话,则继续通过第二处理中过滤器对第一交易标识进行去重过滤。
S1006,在第二处理中过滤器判断区块链上不存在第一交易标识的情况下,将第一交易加入区块链的交易池。
S1008,在第二处理中过滤器判断区块链上存在第一交易标识的情况下,通过区块链的 账本数据库对第一交易标识进行去重判断。
S1010,在通过账本数据库确定区块链上不存在第一交易标识时,将第一交易标识加入区块链的交易池。
S1012,在通过账本数据库确定区块链上存在第一交易标识时,丢弃第一交易。
本实施例提供的技术方案,在第二处理过滤器确定第一交易标识存在的情况下,还会通过账本数据库对第一交易标识进而二次去重,从而提高执行节点中的去重过滤的准确性。
图11是根据一示例性实施例示出的一种交易处理方法的流程图。
参考图11,上述交易处理方法可以包括以下步骤。
S1102,获取区块链中待上链的第一区块。
S1104,在确定第一区块满足第一扩容条件的情况下,根据第一扩容条件在区块链的节点中确定执行过滤器扩容的第一节点。
S1106,从第一节点处获取第一扩容过滤器。
第一扩容过滤器的容量大于执行节点中的第一处理中过滤器的容量,第一扩容过滤器是第一节点根据区块链中已上链的交易生成的。
S1108,将第一区块中的交易加载至第一扩容过滤器,并将第一扩容过滤器作为第二处理中过滤器,以便通过第二处理中过滤器对区块链的待上链的交易进行去重过滤。
S1110,获取待上链的第二区块。
S1112,在确定第二区块满足第二扩容条件的情况下,将第二处理中过滤器进行共识并在共识通过后存储在第二区块中,第一扩容条件和第二扩容条件不同。
S1114,根据第二扩容条件在区块链的节点中确定执行过滤器扩容的第二节点。
其中,第二扩容条件可以是根据实际需求设置的区块的个数、交易的个数等,例如可以是根据过滤器的容量大小设置的区块的个数或者交易的个数等,本公开对此不做限制。可以理解的是,过滤器的容量越大,第二扩容条件中设置的区块的个数越多(即在相同错误率的情况下,容量大的过滤器可以处理的交易(或者区块)越大)。
其中,第一扩容条件与第二扩容条件可以不同,第二扩容条件中设置的区块的个数、交易的个数大于第一扩容条件中设置的区块的个数、交易的个数。另外,第二扩容条件对应的过滤器的容量也大于第一扩容条件对应的过滤器的容量。
S1116,从第二节点处获取第二扩容过滤器,第二扩容过滤器的容量大于第一扩容过滤器。
第二扩容过滤器是第二节点根据区块链中已上链的交易生成的,区块链中已上链的交易包括第一区块中的交易。
S1118,将第二区块中的交易加载至第二扩容过滤器,并将第二扩容过滤器作为第三处理中过滤器,以便通过第三处理中过滤器对区块链的待上链的交易进行去重过滤。
本实施例提高的技术方案,可以在第二处理中过滤器的错误率大于某个阈值(或者区块链中的区块个数或者交易个数大于某个阈值)的情况下,及时地对第二处理中过滤器进行扩容,以提高过滤器地准确率。
在一些实施例中,根据第一扩容条件进行第一扩容过滤器构建的第一节点可以就是本 公开中的执行节点。也就是说,第一节点在执行第一扩容过滤器构建的同时还会执行第一处理中过滤器的构建和使用。
图12是根据一示例性实施例示出的一种扩容过滤器构建方法的流程图。
参考图12,上述扩容过滤器构建方法可以包括以下步骤。
S1202,获取待上链的第三区块。
其中,第一节点可以是区块链中性能较好、计算资源较多的节点。
可想而知,可以让区块链中性能较好、计算资源较多的节点后台构建第一扩容过滤器,这样既不会影响第一节点中的业务,也不会因为第一扩容过滤器的构建对其他节点中的业务造成影响。
S1204,在确定第三区块不满足第一扩容条件的情况下,将第三区块加载至第一处理中过滤器。
S1206,将第三区块加载至第一扩容过滤器,以便第一节点在构建第一处理中过滤器的同时构建第一扩容过滤器。
如图13所示,对于第一节点来说,不仅要执行第一处理中过滤器的构建还会在后台(即内存中)构建第一扩容过滤器。既完成了第一扩容过滤器的构建还不会对区块链中的节点中的业务(可以是业务的执行效率和执行准确度)造成影响。
在一些实施例中,根据第二扩容条件进行第二扩容过滤器构建的第二节点可以就是本公开中的执行节点。也就是说,第二节点在执行第二扩容过滤器构建的同时还会执行第二处理中过滤器的构建和使用。
图14是根据一示例性实施例示出的一种扩容过滤器构建方法的流程图。
参考图14,上述扩容过滤器构建方法可以包括以下步骤。
S1402,获取待上链的第四区块。
S1404,在确定第四区块满足第一扩容条件但不满足第二扩容条件的情况下,将第四区块加载至第二处理中过滤器。
S1406,将第四区块加载至第二扩容过滤器,以便在构建第二处理中过滤器的同时还构建第二扩容过滤器。
如图15所示,对于第二节点来说,不仅要执行第一处理中过滤器的构建还会在后台(即内存中)构建第二扩容过滤器。既完成了第二扩容过滤器的构建还不会对区块链中的节点中的业务(可以是业务的执行效率和执行准确度)造成影响。
在另外一些实施例中,一些节点因为计算资源很多,所以不仅要执行第一处理中过滤器的构建还会在后台(即内存中)构建第一扩容过滤器和第二扩容过滤器(如图16所示)。因此,第一节点和第二节点可以是相同地节点,本公开对此不做限制。
图17是根据一示例性实施例示出的一种扩容条件修改方法的流程图。
参考图17,上述扩容条件修改方法可以包括以下步骤。
S1702,获取第一处理中过滤器的实际错误率。
在一些实施例中,可以根据区块链中已上链的区块或者交易确定第一处理中过滤器的实际错误率,本公开对上述实际错误率的确定方式不做限制,本领域技术人员可以根据实 际需求进行确定。
S1704,确定第一处理中过滤器的实际错误率低于目标错误率。
在一些实施例中,本领域技术人员可以预先设置一目标错误率,该目标错误率与第一扩容条件相对应。
在一些实施例中,当确定第一处理中过滤器的在第N区块上链时对于的实际错误率低于目标错误率或者高于目标错误率时,可以对第一扩容条件进行修改,N为大于1的正整数。
例如,当设置第一扩容条件时,认为在第M个区块上链时第一处理中过滤器的目标错误率会达到某个阈值,应该在第K个区块对第一处理中过滤前进行扩容。而在实际操作中发现,在第M个区块上链时,第一处理中过滤器的目标错误率远远小于目标错误率,那么可以认为第一处理中过滤器还可以继续使用,不着急进行扩容,那么就需要对第一扩容条件进行修改。或者,在实际操作中发现,在第M个区块上链时,第一处理中过滤器的目标错误率大于目标错误率,那么可以认为第一处理中过滤器可能不能够继续使用了,需要及时进行扩容,那么也需要对第一扩容条件进行修改。
S1706,根据实际错误率生成第二交易。
S1708,向区块链提交第二交易,以便区块链对第二交易进行共识。
S1710,在共识通过后,根据第二交易中的内容修改第一扩容条件。
本实施例提供的技术方案,可以通过交易上链的方式对第一扩容条件进行修改,可以便于根据第一处理中过滤器的实际错误率对第一扩容条件进行修改,灵活且有效。
图18是根据一示例性实施例示出的一种去重过滤方法的示意图。
参考图18,上述去重过滤方法可以包括以下步骤。
S1802,获取交易对象。
S1804,获取交易中的TxID(交易唯一key)。
S1806,调用过滤组件,进行交易去重判断。
S1808,获取处理中布隆过滤器。
S1810,锁住(Lock)处理中布隆过滤器。
S1812,使用布隆过滤器对交易进行去重验证。
S1814,将布隆过滤器进行解锁(Unlock)。
在执行S1814的同时,执行S1816,汇总处理中布隆过滤器判断结果。
如果汇总结果中存在该交易对象,则执行S1818,通过账本数据库对交易对象进行判断。
如果汇总结果中不存在该交易对象,则执行S1820,将交易对象加入交易池。
S1822,丢弃结束。
本实施例提供的技术方案,可以对区块链中的待上链交易进行准确的去重过滤。
图19是根据一示例性实施例示出的一种去重过滤方法的示意图。
参考图19,上述去重过滤方法可以包括以下步骤。
S1902,获取第一区块。
S1904,判断第一区块是否满足目标扩容条件。
在判断第一区块不满足目标扩容条件的情况下执行S1906,从内存中获取处理中过滤器。
S1908,将第一区块加载至处理中过滤器中。
在判断第一区块满足目标扩容条件的情况下执行S1910,从内存中获取处理中过滤器,并将第一区块共识后存储在处理中过滤器中。
S1912,在目标区块链中确定根据目标扩容条件进行过滤器扩容的扩容节点。
S1914,从扩容节点获取扩容后过滤器。
S1916,将扩容后过滤器作为处理中过滤器。
S1918,将第一区块加载至处理中过滤器中。
上述实施例,在第一区块满足第一扩容条件时(即处理中过滤器的错误率达到某个阈值),则从区块链的第一节点中获取一已扩容的过滤器作为执行节点的处理中过滤器,以对后续上链的交易进行去重过滤。通过上述方法,一方面执行节点可以在第一区块满足扩容条件时,及时地实现过滤器的扩容,根据该已扩容过滤器继续进行去重过滤能够提高执行节点的去重准确率;另一方面,该扩容过滤器是由区块链中的其他节点构建的,不用占用执行节点的资源,不会对执行节点的业务(例如去重过滤业务)产生任何影响,这对于那些性能较低(例如核数较少)的节点来说即提高了去重准去率又不会对节点自身的业务产生影响;另外,还可以通过将过滤器上链存储,对作恶行为进行追溯,以便增加节点作恶的成本,从而降低节点作恶行为。
图20是根据一示例性实施例示出的一种重新加载过滤器的方法流程图。
本实施例提供一种节点重新加载过滤器的方法。
参考图20,上述重新加载过滤器的方法可以包括以下步骤。
S2002,获取目标区块链的最新区块LastestBlock,加载其中存储的过滤器,设置为LBF。
S2004,判断LBF为空。
在LBF不为空的情况下,执行S2006,从最新区块LastestBlock中获取过滤器,并将该过滤器作为处理中过滤器NBF。
S2008,将处理中过滤器添加至内存中的过滤组件,以便通过该过滤组件对待上链交易进行去重过来。
在LBF为空的情况下,执行S2010,创建空布隆过滤器(NBF)。
S2012,设置BC=最新区块LatestBlock。
S2014,遍历BC中交易,经过计算后加载至NBF。
S2016,设置BC=BC-1。
S2018,判断BC是否是第0个区块。
在BC是第0个区块的情况下,执行S2020,遍历BC中交易,经过计算后加载至NBF。
在BC不是第0个区块的情况下,循环执行S2022,将NBF添加至内存中过滤组件,以便通过该过滤组件对待上链交易进行去重过滤。
经过上述的步骤,节点在启动后就可以将过滤器加载到内存(过滤组件)。
基于同一发明构思,本公开实施例中还提供了一种交易处理装置,如下面的实施例。由于该装置实施例解决问题的原理与上述方法实施例相似,因此该装置实施例的实施可以参见上述方法实施例的实施,重复之处不再赘述。
图21是根据一示例性实施例示出的一种交易处理装置的框图。参照图21,本公开实施例提供的交易处理装置2100可以包括:第一区块获取模块2101、第一节点确定模块2102、第一扩容过滤器确定模块2103和第一区块加载模块2104。该交易处理装置2100可以为区块链上的执行节点。
其中,第一区块获取模块2101可以用于获取所述区块链中待上链的第一区块;第一节点确定模块2102可以用于在确定第一区块满足第一扩容条件的情况下,根据第一扩容条件在区块链的节点中确定执行过滤器扩容的第一节点;第一扩容过滤器确定模块2103可以用于从第一节点处获取第一扩容过滤器,第一扩容过滤器的容量大于执行节点中的第一处理中过滤器的容量,第一扩容过滤器是第一节点根据区块链中已上链的交易生成的;第一区块加载模块2104可以用于将第一区块中的交易加载至第一扩容过滤器,并将第一扩容过滤器作为第二处理中过滤器,以便通过第二处理中过滤器对区块链的待上链的交易进行去重过滤。
此处需要说明的是,上述第一区块获取模块2101、第一节点确定模块2102、第一扩容过滤器确定模块2103以及第一区块加载模块210对应于方法实施例中的S402~S408,上述模块与对应的步骤所实现的示例和应用场景相同,但不限于上述方法实施例所公开的内容。需要说明的是,上述模块作为装置的一部分可以在诸如一组计算机可执行指令的计算机***中执行。
在一些实施例中,交易处理还包括:第一处理中过滤器获取模块、共识模块和存储模块。
其中,第一处理中过滤器获取模块可以用于在将第一扩容过滤器作为第二处理中过滤器之前,从执行节点的内存中获取第一处理中过滤器;共识模块可以用于在确定第一区块满足第一扩容条件的情况下,将第一处理中过滤器进行共识;存储模块可以用于在共识通过后将第一处理中过滤器存储在第一区块中。
在一些实施例中,交易处理装置还可以包括:第一处理中过滤器确定模块和第一区块加载模块。
其中,第一处理中过滤确定模块可以用于在确定第一区块不满足第一扩容条件的情况下,从执行节点的内存中获取第一处理中过滤器;第一区块加载模块可以用于将第一区块中的交易加载至第一处理中过滤器,以便通过第一处理中过滤器对区块链的待上链交易进行去重过滤。
在一些实施例中,第一节点包括第一执行节点;其中,第一扩容过滤器确定模块2103可以包括:第一目标扩容过滤器获取子模块、安全检测子模块、第一扩容过滤器确定子模块。
其中,第一目标扩容过滤器获取子模块可以用于从第一执行节点获取第一目标扩容过滤器;安全检测子模块可以用于对第一目标扩容过滤器进行安全检测;第一扩容过滤器确定子模块可以用于在确定第一目标扩容过滤器安全检测通过的情况下,将第一目标扩容过滤器作为第一扩容过滤器。
在一些实施例中,第一节点还包括第二执行节点;其中,第一扩容过滤器确定模块2103 可以包括:第二目标扩容过滤器获取子模块、第二安全检测子模块、第二目标扩容过滤器转换模块、候选扩容过滤器生成子模块和候选扩容过滤器转换子模块。
其中,第二目标扩容过滤器获取子模块可以用于在确定第一目标扩容过滤器安全检测不通过的情况下,从第二执行节点获取第二目标扩容过滤器;第二安全检测子模块可以用于对第二目标扩容过滤器进行安全检测;第二目标扩容过滤器转换模块可以用于在确定第二目标扩容过滤器安全检测通过的情况下,将第二目标扩容过滤器作为第一扩容过滤器;候选扩容过滤器生成子模块可以用于在确定第二目标扩容过滤器安全检测不通过的情况下,根据区块链中已上链的交易构建候选扩容过滤器,候选扩容过滤器的容量等于第一目标扩容过滤器的容量;候选扩容过滤器转换子模块可以用于将候选扩容过滤器作为第一扩容过滤器。
在一些实施例中,安全检测子模块可以包括:候选扩容过滤器构建单元和安全检测单元。
其中,候选扩容过滤器构建单元可以用于根据区块链中已上链的交易构建候选扩容过滤器,候选扩容过滤器的容量等于第一目标扩容过滤器的容量;安全检测单元可以用于根据候选扩容过滤器对第一目标扩容过滤器进行安全检测。
在一些实施例中,安全检测子模块可以包括:已上链交易获取单元、虚拟交易构建单元和第二安全检测单元。
其中,已上链交易获取单元可以用于从区块链中获取至少一个已上链交易;虚拟交易构建单元可以用于随机构建至少一个虚拟交易;第二安全检测单元可以用于根据至少一个已上链交易和至少一个虚拟交易对第一目标扩容过滤器进行安全检测。
在一些实施例中,交易处理装置还可以包括:交易获取子模块和第一扩容过滤器构建子模块。
其中,交易获取子模块可以用于在未从第一节点处获得第一扩容过滤器的情况下,获取区块链中已上链的交易;第一扩容过滤器构建子模块可以用于根据区块链中已上链的交易构建第一扩容过滤器。
在一些实施例中,交易处理装置还可以包括:第一交易获取模块、去重过滤模块和第一判断模块。
其中,第一交易获取模块可以用于获取第一交易,第一交易包括第一交易标识;去重过滤模块可以用于通过第二处理中过滤器对第一交易标识进行去重过滤;第一判断模块可以用于在第二处理中过滤器判断区块链上不存在第一交易标识的情况下,将第一交易加入区块链的交易池。
在一些实施例中,交易处理装置还可以包括:第二判断模块、第三模块和第四判断模块。
其中,第二判断模块可以用于在第二处理中过滤器判断区块链上存在第一交易标识的情况下,通过区块链的账本数据库对第一交易标识进行去重判断;第三判断模块可以用于在通过账本数据库确定区块链上不存在第一交易标识时,将第一交易标识加入区块链的交易池;第四判断模块可以用于在通过账本数据库确定区块链上存在第一交易标识时,丢弃 第一交易。
在一些实施例中,交易处理装置还可以包括:第二区块获取模块、第二处理中过滤器共识模块、第二节点确定模块、第二扩容过滤器获取模块和第二扩容过滤器加载模块。
其中,第二区块获取模块可以用于获取待上链的第二区块;第二处理中过滤器共识模块可以用于在确定第二区块满足第二扩容条件的情况下,将第二处理中过滤器进行共识并在共识通过后存储在第二区块中,第一扩容条件和第二扩容条件不同;第二节点确定模块可以用于根据第二扩容条件在区块链的节点中确定执行过滤器扩容的第二节点;第二扩容过滤器获取模块可以用于从第二节点处获取第二扩容过滤器,第二扩容过滤器的容量大于第一扩容过滤器,第二扩容过滤器是第二节点根据区块链中已上链的交易生成的,区块链中已上链的交易包括第一区块中的交易;第二扩容过滤器加载模块可以用于将第二区块中的交易加载至第二扩容过滤器,并将第二扩容过滤器作为第三处理中过滤器,以便通过第三处理中过滤器对区块链的待上链的交易进行去重过滤。
在一些实施例中,第一节点是执行节点;交易处理装置还可以包括:第三区块获取模块和同时构建模块。
第三区块获取模块可以用于在从第一节点处获取第一扩容过滤器之前,第一节点获取待上链的第三区块;同时构建模块可以用于在确定第三区块不满足第一扩容条件的情况下,在将第三区块加载至第一处理中过滤器的同时,还将第三区块加载至第一扩容过滤器,以便第一节点在构建第一处理中过滤器的同时构建第一扩容过滤器。
在一些实施例中,执行节点是根据第二扩容条件执行过滤器扩容的第二节点;交易处理装置还可以包括:第四区块获取模块和同时构建模块。
第四区块获取模块可以用于在将所述第一扩容过滤器作为第二处理中过滤器之后,获取待上链的第四区块;同时构建模块可以用于在确定所述第四区块满足所述第一扩容条件但不满足所述第二扩容条件的情况下,将所述第四区块加载至所述第二处理中过滤器;将所述第四区块加载至所述第二扩容过滤器,以便在构建所述第二处理中过滤器的同时还构建所述第二扩容过滤器。
在一些实施例中,交易处理装置还可以包括:扩容条件修改模块,该扩容条件修改模块用于:
获取所述第一处理中过滤器的实际错误率;
确定所述第一处理中过滤器的实际错误率低于目标错误率;
根据所述实际错误率生成第二交易;
向所述区块链提交所述第二交易,以便所述区块链对所述第二交易进行共识;
在共识通过后,根据所述第二交易中的内容修改所述第一扩容条件。
由于装置2100的各功能已在其对应的方法实施例中予以详细说明,本公开于此不再赘述。
描述于本申请实施例中所涉及到的模块和/或子模块和/或单元可以通过软件的方式实现,也可以通过硬件的方式来实现。所描述的模块和/或子模块和/或单元也可以设置在处理器中。其中,这些模块和/或子模块和/或单元的名称在某种情况下并不构成对该模块和/或 子模块和/或单元本身的限定。
附图中的流程图和框图,图示了按照本申请各种实施例的***、方法和计算机程序产品的可能实现的体系架构、功能和操作。在这点上,流程图或框图中的每个方框可以代表一个模块、程序段、或代码的一部分,上述模块、程序段、或代码的一部分包含一个或多个用于实现规定的逻辑功能的可执行指令。也应当注意,在有些作为替换的实现中,方框中所标注的功能也可以以不同于附图中所标注的顺序发生。例如,两个接连地表示的方框实际上可以基本并行地执行,它们有时也可以按相反的顺序执行,这依所涉及的功能而定。也要注意的是,框图或流程图中的每个方框、以及框图或流程图中的方框的组合,可以用执行规定的功能或操作的专用的基于硬件的***来实现,或者可以用专用硬件与计算机指令的组合来实现。
此外,上述附图仅是根据本公开示例性实施例的方法所包括的处理的示意性说明,而不是限制目的。易于理解,上述附图所示的处理并不表明或限制这些处理的时间顺序。另外,也易于理解,这些处理可以是例如在多个模块中同步或异步执行的。
图22示出了适于用来实现本公开实施例的电子设备的结构示意图。需要说明的是,图22示出的电子设备2200仅是一个示例,不应对本公开实施例的功能和使用范围带来任何限制。
如图22所示,电子设备2200包括中央处理单元(CPU)2211,其可以根据存储在只读存储器(ROM)2212中的程序或者从储存部分2218加载到随机访问存储器(RAM)2213中的程序而执行各种适当的动作和处理。在RAM 2213中,还存储有电子设备2200操作所需的各种程序和数据。CPU 2211、ROM 2212以及RAM 2213通过总线2214彼此相连。输入/输出(I/O)接口2215也连接至总线2214。
以下部件连接至I/O接口2215:包括键盘、鼠标等的输入部分2216;包括诸如阴极射线管(CRT)、液晶显示器(LCD)等以及扬声器等的输出部分2217;包括硬盘等的储存部分2218;以及包括诸如LAN卡、调制解调器等的网络接口卡的通信部分2219。通信部分2219经由诸如因特网的网络执行通信处理。驱动器2210也根据需要连接至I/O接口2215。可拆卸介质2211,诸如磁盘、光盘、磁光盘、半导体存储器等等,根据需要安装在驱动器2210上,以便于从其上读出的计算机程序根据需要被安装入储存部分2218。
特别地,根据本公开的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本公开的实施例包括一种计算机程序产品,其包括承载在计算机可读存储介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信部分2219从网络上被下载和安装,和/或从可拆卸介质2211被安装。在该计算机程序被中央处理单元(CPU)2211执行时,执行本申请的***中限定的上述功能。
需要说明的是,本公开所示的计算机可读存储介质可以是计算机可读信号介质或者计算机可读存储介质或者是上述两者的任意组合。计算机可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的***、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连 接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行***、装置或者器件使用或者与其结合使用。而在本申请中,计算机可读的信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读的信号介质还可以是计算机可读存储介质以外的任何计算机可读存储介质,该计算机可读存储介质可以发送、传播或者传输用于由指令执行***、装置或者器件使用或者与其结合使用的程序。计算机可读存储介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:无线、电线、光缆、RF等等,或者上述的任意合适的组合。
另外,本申请实施例还提供了一种存储介质,所述存储介质用于存储计算机程序,所述计算机程序用于执行上述实施例提供的方法。
本申请实施例还提供了一种包括计算机程序的计算机程序产品,当其在计算机上运行时,使得计算机执行上述实施例提供的方法。
通过以上的实施方式的描述,本领域的技术人员易于理解,这里描述的示例实施方式可以通过软件实现,也可以通过软件结合必要的硬件的方式来实现。因此,本公开实施例的技术方案可以以软件产品的形式体现出来,该软件产品可以存储在一个非易失性存储介质(可以是CD-ROM,U盘,移动硬盘等)中,包括若干指令用以使得一台计算设备(可以是个人计算机、服务器、移动终端、或者智能设备等)执行根据本公开实施例的方法,例如图4、图6、图8~图12、图14或图17~图19中的一个或多个所示的步骤。
本领域技术人员在考虑说明书及实践在这里公开的公开后,将容易想到本公开的其他实施例。本公开旨在涵盖本公开的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本公开的一般性原理并包括本公开未申请的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本公开的真正范围和精神由权利要求指出。
应当理解的是,本公开并不限于这里已经示出的详细结构、附图方式或实现方法,相反,本公开意图涵盖包含在所附权利要求的精神和范围内的各种修改和等效设置。

Claims (18)

  1. 一种交易处理方法,所述交易处理方法由区块链上的执行节点执行,所述方法包括:
    获取所述区块链中待上链的第一区块;
    在确定所述第一区块满足第一扩容条件的情况下,根据所述第一扩容条件在所述区块链的节点中确定执行过滤器扩容的第一节点;
    从所述第一节点处获取第一扩容过滤器,所述第一扩容过滤器的容量大于所述执行节点中的第一处理中过滤器的容量,所述第一扩容过滤器是所述第一节点根据所述区块链中已上链的交易生成的;
    将所述第一区块中的交易加载至所述第一扩容过滤器,并将所述第一扩容过滤器作为第二处理中过滤器,以便通过所述第二处理中过滤器对所述区块链的待上链的交易进行去重过滤。
  2. 根据权利要求1所述方法,在将所述第一扩容过滤器作为第二处理中过滤器之前,所述方法还包括:
    从执行节点的内存中获取所述第一处理中过滤器;
    在确定所述第一区块满足第一扩容条件的情况下,将所述第一处理中过滤器进行共识;
    在共识通过后将所述第一处理中过滤器存储在所述第一区块中。
  3. 根据权利要求1所述方法,所述方法还包括:
    在确定所述第一区块不满足第一扩容条件的情况下,从所述执行节点的内存中获取所述第一处理中过滤器;
    将所述第一区块中的交易加载至所述第一处理中过滤器,以便通过所述第一处理中过滤器对所述区块链的待上链交易进行去重过滤。
  4. 根据权利要求1所述方法,所述第一节点包括第一执行节点;其中,从所述第一节点处获取第一扩容过滤器,包括:
    从所述第一执行节点获取第一目标扩容过滤器;
    对所述第一目标扩容过滤器进行安全检测;
    在确定所述第一目标扩容过滤器安全检测通过的情况下,将所述第一目标扩容过滤器作为所述第一扩容过滤器。
  5. 根据权利要求4所述方法,所述第一节点还包括第二执行节点;其中,从所述第一节点处获取第一扩容过滤器,包括:
    在确定所述第一目标扩容过滤器安全检测不通过的情况下,从所述第二执行节点获取第二目标扩容过滤器;
    对所述第二目标扩容过滤器进行安全检测;
    在确定所述第二目标扩容过滤器安全检测通过的情况下,将所述第二目标扩容过滤器作为所述第一扩容过滤器;
    在确定所述第二目标扩容过滤器安全检测不通过的情况下,根据所述区块链中已上链的交易构建候选扩容过滤器,所述候选扩容过滤器的容量等于所述第一目标扩容过滤器的容量;
    将所述候选扩容过滤器作为所述第一扩容过滤器。
  6. 根据权利要求4所述方法,所述对所述第一目标扩容过滤器进行安全检测,包括:
    根据所述区块链中已上链的交易构建候选扩容过滤器,所述候选扩容过滤器的容量等于所述第一目标扩容过滤器的容量;
    根据所述候选扩容过滤器对所述第一目标扩容过滤器进行安全检测。
  7. 根据权利要求4所述方法,所述对所述第一目标扩容过滤器进行安全检测,包括:
    从所述区块链中获取至少一个已上链交易;
    随机构建至少一个虚拟交易;
    根据所述至少一个已上链交易和所述至少一个虚拟交易对所述第一目标扩容过滤器进行安全检测。
  8. 根据权利要求1-7任意一项所述方法,所述方法还包括:
    在未从所述第一节点处获得所述第一扩容过滤器的情况下,获取所述区块链中已上链的交易;
    根据所述区块链中已上链的交易构建所述第一扩容过滤器。
  9. 根据权利要求1-8任意一项所述方法,所述方法还包括:
    获取第一交易,所述第一交易包括第一交易标识;
    通过所述第二处理中过滤器对所述第一交易标识进行去重过滤;
    在所述第二处理中过滤器判断所述区块链上不存在所述第一交易标识的情况下,将所述第一交易加入所述区块链的交易池。
  10. 根据权利要求9所述方法,所述方法还包括:
    在所述第二处理中过滤器判断所述区块链上存在所述第一交易标识的情况下,通过所述区块链的账本数据库对所述第一交易标识进行去重判断;
    在通过所述账本数据库确定所述区块链上不存在所述第一交易标识时,将所述第一交易标识加入所述区块链的交易池;
    在通过所述账本数据库确定所述区块链上存在所述第一交易标识时,丢弃所述第一交易。
  11. 根据权利要求1-10任意一项所述方法,所述方法还包括:
    获取待上链的第二区块;
    在确定所述第二区块满足第二扩容条件的情况下,将所述第二处理中过滤器进行共识并在共识通过后存储在所述第二区块中,所述第一扩容条件和所述第二扩容条件不同;
    根据所述第二扩容条件在所述区块链的节点中确定执行过滤器扩容的第二节点;
    从所述第二节点处获取第二扩容过滤器,所述第二扩容过滤器的容量大于所述第一扩容过滤器,所述第二扩容过滤器是所述第二节点根据所述区块链中已上链的交易生成的,所述区块链中已上链的交易包括所述第一区块中的交易;
    将所述第二区块中的交易加载至所述第二扩容过滤器,并将所述第二扩容过滤器作为第三处理中过滤器,以便通过所述第三处理中过滤器对所述区块链的待上链的交易进行去重过滤。
  12. 根据权利要求1-11任意一项所述方法,所述第一节点是所述执行节点;其中,在从所述第一节点处获取第一扩容过滤器之前,所述方法还包括:
    获取待上链的第三区块;
    在确定所述第三区块不满足所述第一扩容条件的情况下,将所述第三区块加载至所述第一处理中过滤器;
    将所述第三区块加载至所述第一扩容过滤器,以便所述第一节点在构建所述第一处理中过滤器的同时构建所述第一扩容过滤器。
  13. 根据权利要求1-12任意一项所述方法,所述执行节点是根据第二扩容条件执行过滤器扩容的第二节点;其中,在将所述第一扩容过滤器作为第二处理中过滤器之后,所述方法还包括:
    获取待上链的第四区块;
    在确定所述第四区块满足所述第一扩容条件但不满足所述第二扩容条件的情况下,将所述第四区块加载至所述第二处理中过滤器;
    将所述第四区块加载至所述第二扩容过滤器,以便在构建所述第二处理中过滤器的同时还构建所述第二扩容过滤器。
  14. 根据权利要求1-13任意一项所述方法,所述方法还包括:
    获取所述第一处理中过滤器的实际错误率;
    确定所述第一处理中过滤器的实际错误率低于目标错误率;
    根据所述实际错误率生成第二交易;
    向所述区块链提交所述第二交易,以便所述区块链对所述第二交易进行共识;
    在共识通过后,根据所述第二交易中的内容修改所述第一扩容条件。
  15. 一种交易处理装置,所述交易处理装置为区块链上的执行节点,包括:
    第一区块获取模块,用于获取所述区块链中待上链的第一区块;
    第一节点确定模块,用于在确定所述第一区块满足第一扩容条件的情况下,根据所述第一扩容条件在所述区块链的节点中确定执行过滤器扩容的第一节点;
    第一扩容过滤器确定模块,用于从所述第一节点处获取第一扩容过滤器,所述第一扩容过滤器的容量大于所述执行节点中的第一处理中过滤器的容量,所述第一扩容过滤器是所述第一节点根据所述区块链中已上链的交易生成的;
    第一区块加载模块,用于将所述第一区块中的交易加载至所述第一扩容过滤器,并将所述第一扩容过滤器作为第二处理中过滤器,以便通过所述第二处理中过滤器对所述区块链的待上链的交易进行去重过滤。
  16. 一种电子设备,包括:
    存储器;以及
    耦合到所述存储器的处理器,所述处理器被用于基于存储在所述存储器中的计算机程序,执行如权利要求1-14任一项所述的交易处理方法。
  17. 一种计算机可读存储介质,其上存储有计算机程序,该计算机程序被处理器执行时实现如权利要求1-14任一项所述的交易处理方法。
  18. 一种计算机程序产品,包括计算机程序,所述计算机程序存储在计算机可读存储介质中,所述计算机程序被处理器执行时实现权利要求1-14任一项所述方法。
PCT/CN2023/090469 2022-07-19 2023-04-25 交易处理方法、装置、设备、存储介质和程序产品 WO2024016766A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210848919.0 2022-07-19
CN202210848919.0A CN117453662A (zh) 2022-07-19 2022-07-19 交易处理方法、装置、电子设备和计算机可读存储介质

Publications (1)

Publication Number Publication Date
WO2024016766A1 true WO2024016766A1 (zh) 2024-01-25

Family

ID=89595342

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/090469 WO2024016766A1 (zh) 2022-07-19 2023-04-25 交易处理方法、装置、设备、存储介质和程序产品

Country Status (2)

Country Link
CN (1) CN117453662A (zh)
WO (1) WO2024016766A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110503558A (zh) * 2019-08-29 2019-11-26 深圳前海微众银行股份有限公司 一种基于区块链***的处理方法及装置
CN111445333A (zh) * 2020-03-26 2020-07-24 腾讯科技(深圳)有限公司 区块生成方法、装置、计算机设备以及存储介质
WO2020253111A1 (zh) * 2019-06-19 2020-12-24 深圳壹账通智能科技有限公司 区块链节点的自动扩容方法、装置、运维终端及存储介质
CN114218179A (zh) * 2021-11-19 2022-03-22 国网青海省电力公司信息通信公司 一种基于p2p技术的海量日志数据溯源与存储装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2020253111A1 (zh) * 2019-06-19 2020-12-24 深圳壹账通智能科技有限公司 区块链节点的自动扩容方法、装置、运维终端及存储介质
CN110503558A (zh) * 2019-08-29 2019-11-26 深圳前海微众银行股份有限公司 一种基于区块链***的处理方法及装置
CN111445333A (zh) * 2020-03-26 2020-07-24 腾讯科技(深圳)有限公司 区块生成方法、装置、计算机设备以及存储介质
CN114218179A (zh) * 2021-11-19 2022-03-22 国网青海省电力公司信息通信公司 一种基于p2p技术的海量日志数据溯源与存储装置

Also Published As

Publication number Publication date
CN117453662A (zh) 2024-01-26

Similar Documents

Publication Publication Date Title
JP6875557B2 (ja) サービス・データをブロックチェーン・システムに書き込むための方法およびデバイス
CN108846753B (zh) 用于处理数据的方法和装置
US10963447B2 (en) Automatic lock removal method for scalable synchronization in dynamic data structures
CN110019267A (zh) 一种元数据更新方法、装置、***、电子设备及存储介质
CN112559529B (zh) 数据存储方法、装置、计算机设备及存储介质
USRE49914E1 (en) Correlation across non-logging components
CN112965945A (zh) 数据存储方法、装置、电子设备及计算机可读介质
US20190258736A1 (en) Dynamic Execution of ETL Jobs Without Metadata Repository
USRE49866E1 (en) Correlation across non-logging components
USRE49366E1 (en) Correlation across non-logging components
CN110955719B (zh) 一种数据存取处理设备、***和方法
CN109410063B (zh) 基于区块链的交易处理方法、装置和存储介质
CN112860412B (zh) 业务数据处理方法、装置、电子设备及存储介质
CN108776665B (zh) 一种数据处理方法及装置
AU2019241002A1 (en) Transaction processing method and system, and server
US20220036206A1 (en) Containerized distributed rules engine
WO2024016766A1 (zh) 交易处理方法、装置、设备、存储介质和程序产品
CN112527950A (zh) 一种基于MapReduce的图数据删除方法及***
CN111209263A (zh) 数据存储方法、装置、设备及存储介质
CN112559547B (zh) 确定多存储对象副本之间一致性的方法及装置
CN112764897B (zh) 任务请求的处理方法、装置、***及计算机可读存储介质
CN110555158A (zh) 互斥数据处理方法及***、计算机可读存储介质
CN110941683B (zh) 获取空间中对象属性信息的方法、装置、介质和电子设备
CN114978686A (zh) 数字资产上链方法及装置
CN114268540B (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: 23841839

Country of ref document: EP

Kind code of ref document: A1