WO2020248982A1 - Method and device for transaction processing in blockchain - Google Patents

Method and device for transaction processing in blockchain Download PDF

Info

Publication number
WO2020248982A1
WO2020248982A1 PCT/CN2020/095201 CN2020095201W WO2020248982A1 WO 2020248982 A1 WO2020248982 A1 WO 2020248982A1 CN 2020095201 W CN2020095201 W CN 2020095201W WO 2020248982 A1 WO2020248982 A1 WO 2020248982A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
random number
record
processed
number record
Prior art date
Application number
PCT/CN2020/095201
Other languages
French (fr)
Chinese (zh)
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 WO2020248982A1 publication Critical patent/WO2020248982A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/401Transaction verification
    • 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

Definitions

  • the embodiments of the present invention relate to the field of financial technology (Fintech), and in particular to a method and device for transaction processing in a blockchain (BlockChain).
  • a blockchain is a chain composed of a series of blocks. Each block records the data of the block and the hash value of the previous block. In this way, all blocks form a chain one after another.
  • the cryptographic technology and decentralized ideas on which the blockchain is based make the historical information on the chain unable to be tampered with.
  • each account corresponds to a sequence. This sequence starts from zero.
  • the sequence value is increased by one, and the transaction node processes the same sequence according to the sequence value of the transaction sent by the client from small to large.
  • the embodiment of the present invention provides a method and device for processing transactions in a blockchain, which improves the efficiency of transaction processing by transaction nodes.
  • An embodiment of the present invention provides a method for processing transactions in a blockchain, including:
  • the transaction node receives the pending transaction sent by the client, where the pending transaction includes a first random number randomly generated by the client for the pending transaction;
  • the transaction node performs a first verification on the pending transaction; wherein, the first verification includes determining whether the first random number is included in a random number record; the random number record is used to record that the first random number has been passed 1. The random number of each transaction verified;
  • the transaction node After determining that the transaction to be processed passes the first verification, the transaction node records the first random number in the random number record and puts the transaction to be processed into a transaction pool.
  • the client does not need to generate strictly increasing sequence values, and the business logic requirements of the client are reduced, and when one account corresponds to multiple clients, the probability of multiple clients generating the same random number when sending transactions at the same time is also Very small, and further, in order to solve the problem of the client generating the same random number, the first verification is performed on the pending transaction sent by the client, and the random number record is set in the transaction node to receive the pending transaction at the transaction node When, verify whether the first random number in the transaction to be processed already exists in the random number record, if not, determine that the transaction to be processed passes the verification, and further record the first random number of the transaction to be processed in the random number record And put the pending transaction into the transaction pool for subsequent on-chain processing.
  • the transaction node does not need to put the received transaction in the transaction pool and wait for other transaction processing to complete before processing the transaction, which improves the transaction The efficiency of the node in processing transactions, and the guarantee that the transaction node will not process repeated transactions.
  • the random number record includes a first random number record and a second random number record
  • the first random number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain;
  • the second random number record is used to record the random number of each transaction that has been processed on the chain
  • the determining by the transaction node that the transaction to be processed passes the first verification includes:
  • the random number record is divided into a first random number record and a second random number record.
  • the first random number record is stored in the memory of the transaction node. Since the memory of the transaction node is limited, the first random number record is set The number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain, and the random number of each transaction that has been processed on the chain is recorded in the second random number record, thereby ensuring the first random number
  • the amount of data recorded by the data is small, to avoid the problem that the memory of the transaction node exceeds the normal operation of the transaction node.
  • the second random number record includes the random number of the second transaction; the second transaction is a transaction recorded in N blocks with a block height of M to MN, where M is a block chain The block height of the current block, M and N are both positive integers, and M is greater than N.
  • the transaction when obtaining the second random number record, according to the current block height, only the current block and the transactions in the N blocks before the current block can be obtained, and the transaction is determined to be the second transaction.
  • the random number of the second transaction is recorded in the second random number record, that is to say, when the second random number record is obtained, not all the transactions of each block that have been recorded in the blockchain are obtained, but the current area
  • the transaction in a part of the block before the block under the premise that the obtained transaction in each block can be enough to verify the current pending transaction, reduce the workload of the transaction node to obtain the random number of the transaction, and improve the work of the transaction node effectiveness.
  • the method further includes:
  • the first random number is deleted from the first random number record, and the first random number and the block height of the transaction to be processed are correspondingly added to the second random number record to ensure the first random number.
  • the random number record only records the random number of the transaction in the transaction pool that has passed the first verification, and does not record the random number of the transaction that has been on the chain, reducing the amount of data recorded by the first random number, that is, reducing the memory of the node Data storage capacity, further, store the random number of the transaction on the chain and the block height of the exchange in the block correspondingly in the second random number record to ensure that the same transaction is rejected after the same transaction is received .
  • an embodiment of the present invention also provides a device for processing transactions in a blockchain, including:
  • a receiving unit configured to receive a pending transaction sent by a client, where the pending transaction includes a first random number randomly generated by the client for the pending transaction;
  • the processing unit is configured to perform first verification on the pending transaction; wherein the first verification includes determining whether the first random number is included in the random number record; the random number record is used to record that the transaction has passed the The random number of each transaction of the first verification; and after determining that the transaction to be processed passes the first verification, record the first random number in the random number record and put the transaction to be processed into the transaction In the pool.
  • the random number record includes a first random number record and a second random number record
  • the first random number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain;
  • the second random number record is used to record the random number of each transaction that has been processed on the chain
  • the processing unit is specifically used for:
  • the second random number record includes the random number of the second transaction; the second transaction is a transaction recorded in N blocks with a block height of M to MN, where M is a block chain The block height of the current block, M and N are both positive integers, and M is greater than N.
  • processing unit is further configured to:
  • an embodiment of the present invention also provides a computing device, including:
  • Memory used to store program instructions
  • the processor is configured to call the program instructions stored in the memory, and execute the method of transaction processing in the blockchain according to the obtained program.
  • an embodiment of the present invention also provides a computer-readable non-volatile storage medium, including computer-readable instructions.
  • the computer reads and executes the computer-readable instructions, the computer executes the above-mentioned blockchain The method of transaction processing.
  • the embodiment of the present invention also provides a computer program product containing instructions, which when running on a computer, causes the computer to execute the above-mentioned method for processing transactions in the blockchain.
  • FIG. 1 is a schematic diagram of a system architecture provided by an embodiment of the present invention
  • Figure 2 is a schematic diagram of another system architecture provided by an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart of a method for processing transactions in a blockchain according to an embodiment of the present invention
  • FIG. 4 is a schematic structural diagram of a transaction processing device in a blockchain provided by an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a computing device provided by this application.
  • FIG. 1 exemplarily shows a system architecture applicable to a method for processing transactions in a blockchain provided by an embodiment of the present invention.
  • the system architecture may include multiple clients 100 and a blockchain system 200, as shown in FIG. 2,
  • the blockchain system 200 includes multiple blockchain nodes 210.
  • the blockchain nodes 210 are transaction nodes. Multiple clients 100 can send transactions to the blockchain nodes 210 respectively.
  • Each block chain node 210 of the block chain system 200 includes a transaction pool 211, a consensus module 212, a synchronization module 213, a block link port module 214, a storage module 215, and the like.
  • the transaction pool 211 is used to receive new transactions from the client 100 or other blockchain nodes 210, and store the verified transactions in the transaction pool queue for use by the consensus module 212 when packaging blocks.
  • the transaction pool 211 may include a transaction validator, which is used to verify the new transaction received from the client. It may include multiple verifications, such as verifying whether the signature of the received transaction is valid, whether it is in the transaction pool or the blockchain There is the transaction, whether the parameters in the transaction are valid, etc.
  • the consensus module 212 is divided into two sub-modules: a packaging thread and a consensus thread.
  • the packaging thread is responsible for taking out transactions from the transaction pool 211, packaging them into blocks, and broadcasting the newly generated blocks to all other consensus nodes; the consensus thread is responsible for executing new blocks , Run the consensus algorithm, write all consensus blocks into the storage module 215 through the block link port module 214.
  • the synchronization module 213 is used for transaction synchronization and block synchronization.
  • the transaction synchronization broadcasts all transactions received by this node to other consensus nodes to ensure that when the block node is switched, the new block node can generate a new block based on the latest transaction ;
  • Block synchronization is used to solve the problem of block height inconsistency between nodes with different performance.
  • the synchronization module 213 maintains the block height information of all nodes. When the block height of the current node lags behind other nodes, it will actively initiate a block download Request to ensure that the block height of this node is consistent with other nodes.
  • the storage module 215 includes two parts: storage and state.
  • Storage (such as AMDB, LevelDB) uses a table-like storage structure, which is mainly used to store block information, system tables, etc.; state stores transaction execution results, including mpt state and storage state, mpt state is a world state tree, which can trace the historical information of any transaction, storage state stores the current state after the transaction is executed, and does not store historical information.
  • FIG. 3 exemplarily shows a flow of a method for processing transactions in a blockchain provided by an embodiment of the present invention, and the flow may be executed by a device for processing transactions in the blockchain.
  • the process specifically includes:
  • Step 301 The transaction node receives the pending transaction sent by the client.
  • the client sends a transaction to be processed, and the transaction to be processed may include a first random number, which is a random value (Nonce value) randomly generated by the client for the transaction to be processed.
  • the client can introduce any random variable to generate a random value, and the client can use a random number of type u256.
  • the client does not need to generate strictly increasing sequence values, and the business logic requirements of the client are reduced, and when an account corresponds to multiple clients, the probability that multiple clients generate the same random number when sending transactions It is also very small. Further, in order to solve the problem of the client generating the same random number, the first verification of the pending transaction sent by the client is required.
  • Step 302 The transaction node performs first verification on the transaction to be processed.
  • the transaction node performs the first verification of the transaction to be processed. Specifically, it can be to verify the first random number in the transaction to be verified, and determine whether the first random number has been recorded in the random number record, which is equivalent to judging whether the random number record includes The first random number.
  • the random number record is used to record the random number of each transaction that has passed the first verification, that is, to determine whether the first random number in a transaction to be processed is in the random number record, if not, determine the The transaction to be processed passes the first verification, and the first random number of the transaction to be processed is added to the random number record.
  • the random number record may include a first random number record and a second random number record, where the first random number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain. ;
  • the second random number record is used to record the random number of each transaction that has been processed on the chain. That is, the transaction node performs the first verification of the transaction to be processed, which may include two verifications. One is to determine that the first random number does not exist in the first random number record, and the other is to determine that the second random number record does not exist. A random number.
  • the first random number record may be a random number list stored in memory, and it may also be called a transaction pool Nonce list, which is used to prevent the transaction pool from processing repeated transactions;
  • the second random number record may also It is a list of random numbers, stored in the database, and can also be called a list of Nonce system tables to prevent the consensus thread from packaging and processing repeated transactions.
  • the second random number record When obtaining the second random number record, it can be obtained according to the current block of the blockchain and the N blocks before the current block. If the block height of the current block of the blockchain is M, then the block height is obtained Is the random number of all transactions in the N blocks from M to MN. If the determined transaction is the second transaction, then the random number of the determined transaction is the random number of the second transaction. The random number is recorded in the second random number record.
  • M and N are positive integers, and M is greater than N.
  • N can be understood as the limit value of the transaction weight prevention (Limit) value, that is, the block range of the transaction weight prevention.
  • the current block to the Nth block in the future is understood as the upper limit of the transaction weight (BlockLimit), which is the block height used to indicate the upper limit of the weight. Assuming the current block is M, then M+N is the upper limit of the transaction weight The height of the block, where N can be set based on experience and can be set to 1000. Further, when obtaining the second random number record, the obtained random numbers of all the second transactions in the N blocks are not repeated.
  • the pending transaction sent by the client may also include a height parameter, which is used to indicate that the block height of the transaction to be processed in the block is not greater than the height parameter. Accordingly, the transaction node performs the first verification of the transaction to be processed , Can include not only judging whether the first random number is included in the random number record, but also judging whether the height parameter in the transaction to be processed is valid according to the block height of the current block of the blockchain.
  • the height parameter is determined to be valid, for example, such as the current block height It is 1500, the default value is 1000, and the height parameter in the transaction to be processed sent by the client is 1700, then it is determined that 1700 is not less than 1500 and not more than 2500, then the height parameter is 1700 is valid.
  • the preset value can be determined based on experience, or it can be a transaction weight prevention limit value.
  • the height parameter is used to indicate the priority of pending transactions sent by the client to meet the different needs of the client for sending transactions.
  • Step 303 After determining that the transaction to be processed passes the first verification, the transaction node records the first random number in the random number record and puts the transaction to be processed into a transaction pool.
  • the transaction to be processed can be Put it in the transaction pool, and then process the transactions in the transaction pool on the chain. Specifically, the pending transactions in the transaction pool can be packaged into blocks, and then the blocks can be chained by consensus. After the pending transactions in the transaction pool are processed on the chain, the first random number can be deleted from the first random number record, and the first random number and the pending transaction can be added correspondingly to the block height of the block To the second random number record.
  • the block height of the transaction to be processed in the block is understood as the block height of the block chain where the transaction to be processed is packaged into the block when the block is chained.
  • the client sends the transaction to be processed to the transaction node.
  • the transaction to be processed has the first random number recorded, and the transaction to be processed is T i , and the first random number of the transaction to be processed T i is Nonce i ; the transaction node receives after T i, call transaction transaction validator pool verify the validity of T i, including three verification:
  • T i Whether T i is duplicated: first query the Nonce list of the transaction pool. If Nonce i exists in the Nonce list of the transaction pool, it means that the transaction pool has received the same transaction and rejected T i ; otherwise, continue to query the Nonce system table list to determine whether T i is available on the transaction chain, if Nonce Nonce system table I present in the list, the transaction has been described on the same chain, reject T i;
  • T i passes the above three verifications of the transaction validator, it is determined that T i can be processed on the chain, and T i is determined to be a verified transaction. Specifically, the random number Nonce i of T i is inserted into the transaction pool Nonce list, and remove the module from the transaction by consensus pool T i and packaged into blocks, block after consensus is successful, will be submitted to the storage module block by block link interface module, about to block the chain. After successfully uploading the block to the chain, first update the Nonce system table list, append the Nonce i of the block to the Nonce system table list, and then update the transaction pool Nonce list, and delete Nonce i from the transaction pool Nonce list.
  • the first random number generated by the client uniquely represents a transaction.
  • Nonce i is inserted into the Nonce list of the transaction pool.
  • the transaction node When there is a second pending transaction with the random number Nonce i
  • the transaction node When submitting to the transaction node again, the transaction node will reject the second pending transaction because the Nonce i already exists in the Nonce list of the transaction pool. And after adding Nonce i to the Nonce system table list, delete Nonce i from the Nonce list of the transaction pool.
  • the transaction node will be affected by the Nonce system table. The Nonce i already exists in the list and the second pending transaction is rejected.
  • the consensus module can periodically package multiple verified transactions from the transaction pool, that is, after the block is successfully uploaded to the chain, the new area There are multiple on-chain transactions in the block, and the first random numbers in the multiple on-chain transactions form a Nonce list. All the first random numbers in the Nonce list are deleted from the Nonce list of the transaction pool and added to the Nonce system table. List.
  • the client does not need to generate strictly increasing sequence values, and the business logic requirements of the client are reduced, and when one account corresponds to multiple clients, the probability of multiple clients generating the same random number when sending transactions at the same time is also Very small, and further, in order to solve the problem of the client generating the same random number, the first verification is performed on the pending transaction sent by the client, and the random number record is set in the transaction node to receive the pending transaction at the transaction node When, verify whether the first random number in the transaction to be processed already exists in the random number record, if not, determine that the transaction to be processed passes the verification, and further record the first random number of the transaction to be processed in the random number record The transaction node does not need to put the received transaction in the transaction pool and wait for the completion of other transaction processing before processing the transaction, and the pending transaction is processed on the chain, which improves the efficiency of transaction processing by the transaction node and guarantees the transaction The node will not process duplicate transactions.
  • FIG. 4 exemplarily shows the structure of a device for processing transactions in a blockchain according to an embodiment of the present invention, and the device can execute the flow of the method for processing transactions in the blockchain.
  • the device includes:
  • the receiving unit 401 is configured to receive a pending transaction sent by a client, where the pending transaction includes a first random number randomly generated by the client for the pending transaction;
  • the processing unit 402 is configured to perform a first verification on the pending transaction; wherein the first verification includes determining whether the first random number is included in a random number record; the random number record is used to record that the transaction has passed The random number of each transaction of the first verification; and after determining that the transaction to be processed passes the first verification, record the first random number in the random number record and place the transaction to be processed In the trading pool.
  • the random number record includes a first random number record and a second random number record
  • the first random number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain;
  • the second random number record is used to record the random number of each transaction that has been processed on the chain
  • the processing unit 402 is specifically configured to:
  • the second random number record includes the random number of the second transaction; the second transaction is a transaction recorded in N blocks with a block height of M to MN, where M is a block chain The block height of the current block, M and N are both positive integers, and M is greater than N.
  • processing unit 402 is further configured to:
  • the present application also provides a computing device.
  • the computing device includes at least one processor 520 for implementing the method in FIG. 3 provided by the embodiment of the present application. Any method.
  • the computing device 500 may also include at least one memory 530 for storing program instructions and/or data.
  • the memory 530 and the processor 520 are coupled.
  • the coupling in the embodiments of the present application is an indirect coupling or communication connection between devices, units, or modules, and may be in electrical, mechanical or other forms, and is used for information exchange between devices, units or modules.
  • the processor 520 may cooperate with the memory 530 to operate.
  • the processor 520 may execute program instructions stored in the memory 530. At least one of the at least one memory may be included in the processor.
  • the steps of the above method can be completed by hardware integrated logic circuits in the processor or instructions in the form of software.
  • the steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware processor, or executed and completed by a combination of hardware and software modules in the processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers.
  • the storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware. To avoid repetition, it will not be described in detail here.
  • the processor in the embodiment of the present application may be an integrated circuit chip with signal processing capability.
  • the steps of the foregoing method embodiments can be completed by hardware integrated logic circuits in the processor or instructions in the form of software.
  • the above-mentioned processor may be a general-purpose processor, a digital signal processing circuit (digital signal processor, DSP), a dedicated integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field programmable gate array, FPGA) or other Programming logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • DSP digital signal processing circuit
  • ASIC application specific integrated circuit
  • FPGA field programmable gate array
  • Programming logic devices discrete gates or transistor logic devices, discrete hardware components.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers.
  • the storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
  • the memory in the embodiment of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory.
  • the non-volatile memory can be read-only memory (ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), and electronic Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory.
  • the volatile memory may be random access memory (RAM), which is used as an external cache.
  • RAM random access memory
  • static random access memory static random access memory
  • dynamic RAM dynamic random access memory
  • DRAM dynamic random access memory
  • SDRAM synchronous dynamic random access memory
  • double data rate synchronous dynamic random access memory double data rate SDRAM, DDR SDRAM
  • enhanced synchronous dynamic random access memory enhanced SDRAM, ESDRAM
  • serial link DRAM SLDRAM
  • direct rambus RAM direct rambus RAM
  • the computing device 500 may further include a communication interface 510 for communicating with other devices through a transmission medium, so that the apparatus used in the computing device 500 can communicate with other devices.
  • the communication interface may be a transceiver, circuit, bus, module, or other type of communication interface.
  • the transceiver when the communication interface is a transceiver, the transceiver may include an independent receiver and an independent transmitter; it may also be a transceiver with integrated transceiver functions, or an interface circuit.
  • the computing device 500 may also include a communication line 540.
  • the communication interface 510, the processor 520, and the memory 530 may be connected to each other through a communication line 540;
  • the communication line 540 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (extended industry standard architecture). , Referred to as EISA) bus and so on.
  • the communication line 540 can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one thick line is used in FIG. 5 to represent, but it does not mean that there is only one bus or one type of bus.
  • embodiments of the present invention also provide a computer-readable non-volatile storage medium, including computer-readable instructions.
  • the computer reads and executes the computer-readable instructions, the computer executes the aforementioned blocks. The method of transaction processing in the chain.
  • the embodiments of the present application provide a computer program product containing instructions, which when running on a computer, cause the computer to execute the above-mentioned method of transaction processing in the blockchain.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.

Abstract

A method and device for transaction processing in a blockchain, which relate to the technical field of finance; the method comprises: a transaction node receiving a transaction to be processed that is sent by a client (301), the transaction to be processed comprising a first random number randomly generated by the client for the transaction to be processed; the transaction node performing first verification on the transaction to be processed (302); and after the transaction node determines that the transaction to be processed passes the first verification, recording the first random number in a random number record and placing the transaction to be processed into a transaction pool (303). Thus, the efficiency of transaction nodes when processing transactions is improved.

Description

一种区块链中交易处理的方法及装置Method and device for transaction processing in block chain
相关申请的交叉引用Cross references to related applications
本申请要求在2019年06月14日提交中国专利局、申请号为201910514704.3、申请名称为“一种区块链中交易处理的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office, the application number is 201910514704.3, and the application name is "a method and device for transaction processing in the blockchain" on June 14, 2019, the entire content of which is by reference Incorporated in this application.
技术领域Technical field
本发明实施例涉及金融科技(Fintech)领域,尤其涉及一种区块链(BlockChain)中交易处理的方法及装置。The embodiments of the present invention relate to the field of financial technology (Fintech), and in particular to a method and device for transaction processing in a blockchain (BlockChain).
背景技术Background technique
随着计算机技术的发展,越来越多的技术应用在金融领域,传统金融业正在逐步向金融科技转变,区块链传输技术也不例外,但由于金融、支付行业的安全性、实时性要求,也对技术提出的更高的要求。With the development of computer technology, more and more technologies are applied in the financial field. The traditional financial industry is gradually transforming to financial technology. Blockchain transmission technology is no exception, but due to the security and real-time requirements of the financial and payment industries , But also higher requirements for technology.
区块链是由一系列区块组成的一条链,每个区块记录本块的数据及上一块的哈希值,所有区块通过这种方式前后相继组成一条链。区块链所基于的密码学技术和去中心化思想使链上的历史信息无法被篡改。A blockchain is a chain composed of a series of blocks. Each block records the data of the block and the hash value of the previous block. In this way, all blocks form a chain one after another. The cryptographic technology and decentralized ideas on which the blockchain is based make the historical information on the chain unable to be tampered with.
客户端将交易发送至区块链时,由于网络等原因,客户端可能多次发送相同的交易,为了防止相同交易被多次处理,现有技术中采用严格递增序列的方式实现交易防重,具体的,每个账户对应一个序列,这个序列从零开始计数,账户所在的客户端每发送一笔交易,序列值加一,交易节点按照客户端发送交易的序列值从小到大顺序处理同一个账户的交易,若节点接收到的交易的序列值远大于当前节点已处理的交易的序列值,则将该接收到的交易放在交易池中,直至处理到该序列值的交易后才会处理该笔交易,该种方式下交易节点处理交易的效率低,且客户端需要生成严格递增的序列值,对客户端的要求较高。When the client sends a transaction to the blockchain, due to network and other reasons, the client may send the same transaction multiple times. In order to prevent the same transaction from being processed multiple times, the prior art adopts a strict incremental sequence to achieve transaction weight prevention. Specifically, each account corresponds to a sequence. This sequence starts from zero. Each time the client where the account is located sends a transaction, the sequence value is increased by one, and the transaction node processes the same sequence according to the sequence value of the transaction sent by the client from small to large. For account transactions, if the sequence value of the transaction received by the node is much greater than the sequence value of the transaction processed by the current node, the received transaction will be placed in the transaction pool and will not be processed until the transaction with the sequence value is processed For this transaction, the efficiency of transaction processing by the transaction node in this manner is low, and the client needs to generate strictly increasing sequence values, which places higher requirements on the client.
发明内容Summary of the invention
本发明实施例提供一种区块链中交易处理的方法及装置,提高交易节点处理交易时的效率。The embodiment of the present invention provides a method and device for processing transactions in a blockchain, which improves the efficiency of transaction processing by transaction nodes.
本发明实施例提供的一种区块链中交易处理的方法,包括:An embodiment of the present invention provides a method for processing transactions in a blockchain, including:
交易节点接收客户端发送的待处理交易,所述待处理交易包括所述客户端为所述待处理交易随机生成的第一随机数;The transaction node receives the pending transaction sent by the client, where the pending transaction includes a first random number randomly generated by the client for the pending transaction;
所述交易节点对所述待处理交易进行第一验证;其中,所述第一验证包括确定随机数记录中是否包括所述第一随机数;所述随机数记录用于记录已通过所述第一验证的各交易的随机数;The transaction node performs a first verification on the pending transaction; wherein, the first verification includes determining whether the first random number is included in a random number record; the random number record is used to record that the first random number has been passed 1. The random number of each transaction verified;
所述交易节点确定所述待处理交易通过所述第一验证后,将所述第一随机数记录于所述随机数记录中并将所述待处理交易放入交易池中。After determining that the transaction to be processed passes the first verification, the transaction node records the first random number in the random number record and puts the transaction to be processed into a transaction pool.
上述技术方案中,客户端无需生成严格递增的序列值,对客户端的业务逻辑要求降低,且在一个账户对应多个客户端时,多个客户端在同时发送交易时生成相同随机数的概率也非常小,进一步的,为解决客户端生成相同随机数的问题,则对客户端发送的待处理交易 进行第一验证,在交易节点中设置随机数记录,用于在交易节点接收到待处理交易时,验证待处理交易中的第一随机数是否已经存在于随机数记录中,若否,则确定该待处理交易通过验证,并进一步将该待处理交易的第一随机数记录于随机数记录中,以及将该待处理交易放入交易池中,用于后续的上链处理,交易节点无需将接收到的交易放在交易池中等待其他交易处理完成后才处理该笔交易,提高了交易节点处理交易的效率,且保障交易节点不会处理重复交易。In the above technical solution, the client does not need to generate strictly increasing sequence values, and the business logic requirements of the client are reduced, and when one account corresponds to multiple clients, the probability of multiple clients generating the same random number when sending transactions at the same time is also Very small, and further, in order to solve the problem of the client generating the same random number, the first verification is performed on the pending transaction sent by the client, and the random number record is set in the transaction node to receive the pending transaction at the transaction node When, verify whether the first random number in the transaction to be processed already exists in the random number record, if not, determine that the transaction to be processed passes the verification, and further record the first random number of the transaction to be processed in the random number record And put the pending transaction into the transaction pool for subsequent on-chain processing. The transaction node does not need to put the received transaction in the transaction pool and wait for other transaction processing to complete before processing the transaction, which improves the transaction The efficiency of the node in processing transactions, and the guarantee that the transaction node will not process repeated transactions.
可选的,所述随机数记录包括第一随机数记录和第二随机数记录;Optionally, the random number record includes a first random number record and a second random number record;
所述第一随机数记录用于记录已通过所述第一验证但未进行上链处理的各交易的随机数;The first random number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain;
所述第二随机数记录用于记录已进行所述上链处理的各交易的随机数;The second random number record is used to record the random number of each transaction that has been processed on the chain;
所述交易节点确定所述待处理交易通过所述第一验证,包括:The determining by the transaction node that the transaction to be processed passes the first verification includes:
确定所述第一随机数记录中不存在所述第一随机数后,确定所述第二随机数记录中不存在所述第一随机数。After determining that the first random number does not exist in the first random number record, it is determined that the first random number does not exist in the second random number record.
上述技术方案中,将随机数记录分为第一随机数记录和第二随机数记录,其中,第一随机数记录是存储在交易节点内存中,由于交易节点内存有限,所以设定第一随机数记录用于记录已通过第一验证但未进行上链处理的各交易的随机数,并将已进行上链处理的各交易的随机数记录在第二随机数记录中,从而保障第一随机数记录的数据量小,避免出现交易节点内存超出影响交易节点的正常工作的问题。In the above technical solution, the random number record is divided into a first random number record and a second random number record. The first random number record is stored in the memory of the transaction node. Since the memory of the transaction node is limited, the first random number record is set The number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain, and the random number of each transaction that has been processed on the chain is recorded in the second random number record, thereby ensuring the first random number The amount of data recorded by the data is small, to avoid the problem that the memory of the transaction node exceeds the normal operation of the transaction node.
可选的,所述第二随机数记录包括第二交易的随机数;所述第二交易是区块高度为M至M-N的N个区块中记录的交易,其中,M为区块链的当前区块的区块高度,M和N均为正整数,且M大于N。Optionally, the second random number record includes the random number of the second transaction; the second transaction is a transaction recorded in N blocks with a block height of M to MN, where M is a block chain The block height of the current block, M and N are both positive integers, and M is greater than N.
上述技术方案中,在获取第二随机数记录时,可以根据当前区块高度,仅获取当前区块以及当前区块之前的共N个区块中的交易,确定该交易为第二交易,将第二交易的随机数记录于第二随机数记录中,也就是说,在获取第二随机数记录时,不是获取全部的已经记录在区块链中的各区块的交易,而是获取当前区块之前的一部分区块中的交易,在保障获取到的各区块中的交易可以足够对当前待处理交易进行验证的前提下,降低交易节点获取交易的随机数的工作量,提高交易节点的工作效率。In the above technical solution, when obtaining the second random number record, according to the current block height, only the current block and the transactions in the N blocks before the current block can be obtained, and the transaction is determined to be the second transaction. The random number of the second transaction is recorded in the second random number record, that is to say, when the second random number record is obtained, not all the transactions of each block that have been recorded in the blockchain are obtained, but the current area The transaction in a part of the block before the block, under the premise that the obtained transaction in each block can be enough to verify the current pending transaction, reduce the workload of the transaction node to obtain the random number of the transaction, and improve the work of the transaction node effectiveness.
可选的,所述交易节点在将所述待处理交易放入交易池中之后,还包括:Optionally, after the transaction node puts the pending transaction into the transaction pool, the method further includes:
将所述交易池中的待处理交易打包成区块并对所述区块进行共识上链;Package the pending transactions in the transaction pool into blocks and perform consensus on the blocks on the chain;
将所述第一随机数从所述第一随机数记录中删除,并将所述第一随机数、所述待处理交易所在区块的区块高度对应添加至所述第二随机数记录中。Delete the first random number from the first random number record, and add the first random number and the block height of the transaction to be processed to the second random number record correspondingly in.
上述技术方案中,将第一随机数从第一随机数记录中删除,以及将第一随机数、待处理交易所在区块的区块高度对应添加至第二随机数记录中,保障第一随机数记录中仅记录当前已通过第一验证的交易池中的交易的随机数,而不记录已上链的交易的随机数,降低第一随机数记录的数据量,即降低节点内存中的数据存储量,进一步的,将已上链的交易的随机数以及交易所在区块的区块高度对应存储在第二随机数记录中,保障在接收到相同交易后,将该相同交易拒绝掉。In the above technical solution, the first random number is deleted from the first random number record, and the first random number and the block height of the transaction to be processed are correspondingly added to the second random number record to ensure the first random number. The random number record only records the random number of the transaction in the transaction pool that has passed the first verification, and does not record the random number of the transaction that has been on the chain, reducing the amount of data recorded by the first random number, that is, reducing the memory of the node Data storage capacity, further, store the random number of the transaction on the chain and the block height of the exchange in the block correspondingly in the second random number record to ensure that the same transaction is rejected after the same transaction is received .
相应的,本发明实施例还提供了一种区块链中交易处理的装置,包括:Correspondingly, an embodiment of the present invention also provides a device for processing transactions in a blockchain, including:
接收单元,用于接收客户端发送的待处理交易,所述待处理交易包括所述客户端为所述待处理交易随机生成的第一随机数;A receiving unit, configured to receive a pending transaction sent by a client, where the pending transaction includes a first random number randomly generated by the client for the pending transaction;
处理单元,用于对所述待处理交易进行第一验证;其中,所述第一验证包括确定随机数记录中是否包括所述第一随机数;所述随机数记录用于记录已通过所述第一验证的各交易的随机数;以及确定所述待处理交易通过所述第一验证后,将所述第一随机数记录于所述随机数记录中并将所述待处理交易放入交易池中。The processing unit is configured to perform first verification on the pending transaction; wherein the first verification includes determining whether the first random number is included in the random number record; the random number record is used to record that the transaction has passed the The random number of each transaction of the first verification; and after determining that the transaction to be processed passes the first verification, record the first random number in the random number record and put the transaction to be processed into the transaction In the pool.
可选的,所述随机数记录包括第一随机数记录和第二随机数记录;Optionally, the random number record includes a first random number record and a second random number record;
所述第一随机数记录用于记录已通过所述第一验证但未进行上链处理的各交易的随机数;The first random number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain;
所述第二随机数记录用于记录已进行所述上链处理的各交易的随机数;The second random number record is used to record the random number of each transaction that has been processed on the chain;
所述处理单元具体用于:The processing unit is specifically used for:
确定所述第一随机数记录中不存在所述第一随机数后,确定所述第二随机数记录中不存在所述第一随机数。After determining that the first random number does not exist in the first random number record, it is determined that the first random number does not exist in the second random number record.
可选的,所述第二随机数记录包括第二交易的随机数;所述第二交易是区块高度为M至M-N的N个区块中记录的交易,其中,M为区块链的当前区块的区块高度,M和N均为正整数,且M大于N。Optionally, the second random number record includes the random number of the second transaction; the second transaction is a transaction recorded in N blocks with a block height of M to MN, where M is a block chain The block height of the current block, M and N are both positive integers, and M is greater than N.
可选的,所述处理单元还用于:Optionally, the processing unit is further configured to:
在所述在将所述待处理交易放入交易池中之后,将所述交易池中的待处理交易打包成区块并对所述区块进行共识上链;After placing the pending transaction in the transaction pool, package the pending transaction in the transaction pool into a block, and perform a consensus upload on the block;
将所述第一随机数从所述第一随机数记录中删除,并将所述第一随机数、所述待处理交易所在区块的区块高度对应添加至所述第二随机数记录中。Delete the first random number from the first random number record, and add the first random number and the block height of the transaction to be processed to the second random number record correspondingly in.
相应的,本发明实施例还提供了一种计算设备,包括:Correspondingly, an embodiment of the present invention also provides a computing device, including:
存储器,用于存储程序指令;Memory, used to store program instructions;
处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行上述区块链中交易处理的方法。The processor is configured to call the program instructions stored in the memory, and execute the method of transaction processing in the blockchain according to the obtained program.
相应的,本发明实施例还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行上述区块链中交易处理的方法。Correspondingly, an embodiment of the present invention also provides a computer-readable non-volatile storage medium, including computer-readable instructions. When the computer reads and executes the computer-readable instructions, the computer executes the above-mentioned blockchain The method of transaction processing.
相应的,本发明实施例还提供了一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述区块链中交易处理的方法。Correspondingly, the embodiment of the present invention also provides a computer program product containing instructions, which when running on a computer, causes the computer to execute the above-mentioned method for processing transactions in the blockchain.
附图说明Description of the drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly describe the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings needed in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative work, other drawings can be obtained from these drawings.
图1为本发明实施例提供的一种系统架构的示意图;FIG. 1 is a schematic diagram of a system architecture provided by an embodiment of the present invention;
图2为本发明实施例提供的另一种系统架构的示意图;Figure 2 is a schematic diagram of another system architecture provided by an embodiment of the present invention;
图3为本发明实施例提供的一种区块链中交易处理的方法的流程示意图;3 is a schematic flowchart of a method for processing transactions in a blockchain according to an embodiment of the present invention;
图4为本发明实施例提供的一种区块链中交易处理的装置的结构示意图;4 is a schematic structural diagram of a transaction processing device in a blockchain provided by an embodiment of the present invention;
图5为本申请提供的一种计算设备的结构示意图。FIG. 5 is a schematic structural diagram of a computing device provided by this application.
具体实施方式Detailed ways
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。In order to make the objectives, technical solutions and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
图1示例性的示出了本发明实施例提供区块链中交易处理的方法所适用的系统架构,该系统架构可以包括多个客户端100和区块链系统200,结合图2所示,区块链系统200中包括多个区块链节点210,区块链节点210即交易节点,多个客户端100可以分别向区块链节点210发送交易。FIG. 1 exemplarily shows a system architecture applicable to a method for processing transactions in a blockchain provided by an embodiment of the present invention. The system architecture may include multiple clients 100 and a blockchain system 200, as shown in FIG. 2, The blockchain system 200 includes multiple blockchain nodes 210. The blockchain nodes 210 are transaction nodes. Multiple clients 100 can send transactions to the blockchain nodes 210 respectively.
区块链系统200的各区块链节点210中包括交易池211、共识模块212、同步模块213、区块链接口模块214、存储模块215等。Each block chain node 210 of the block chain system 200 includes a transaction pool 211, a consensus module 212, a synchronization module 213, a block link port module 214, a storage module 215, and the like.
交易池211用于从客户端100或其他区块链节点210接收新交易,并将验证通过的交易存放到交易池队列中,供共识模块212打包区块时使用。交易池211中可以包括交易验证器,用于对从客户端接收到新交易进行验证,可以包括多种验证,如验证接收到的该笔交易的签名是否有效、交易池或区块链中是否存在该笔交易、该笔交易中的参数是否有效等。The transaction pool 211 is used to receive new transactions from the client 100 or other blockchain nodes 210, and store the verified transactions in the transaction pool queue for use by the consensus module 212 when packaging blocks. The transaction pool 211 may include a transaction validator, which is used to verify the new transaction received from the client. It may include multiple verifications, such as verifying whether the signature of the received transaction is valid, whether it is in the transaction pool or the blockchain There is the transaction, whether the parameters in the transaction are valid, etc.
共识模块212分为打包线程和共识线程两个子模块,打包线程负责从交易池211中取出交易,打包成区块,并将新生成的区块广播给其他所有共识节点;共识线程负责执行新区块、运行共识算法,将所有达成共识的区块通过区块链接口模块214写入存储模块215。The consensus module 212 is divided into two sub-modules: a packaging thread and a consensus thread. The packaging thread is responsible for taking out transactions from the transaction pool 211, packaging them into blocks, and broadcasting the newly generated blocks to all other consensus nodes; the consensus thread is responsible for executing new blocks , Run the consensus algorithm, write all consensus blocks into the storage module 215 through the block link port module 214.
同步模块213用于交易同步和区块同步,交易同步会将本节点接收到的所有的交易广播到其他共识节点,从而保证切换出块节点时,新的出块节点能基于最新交易产生新区块;区块同步则用来解决性能不同节点间区块高度不一致的问题,同步模块213维护着所有节点的区块高度信息,当本节点区块高度落后于其他节点时,会主动发起区块下载请求,从而保证本节点区块高度与其他节点一致。The synchronization module 213 is used for transaction synchronization and block synchronization. The transaction synchronization broadcasts all transactions received by this node to other consensus nodes to ensure that when the block node is switched, the new block node can generate a new block based on the latest transaction ; Block synchronization is used to solve the problem of block height inconsistency between nodes with different performance. The synchronization module 213 maintains the block height information of all nodes. When the block height of the current node lags behind other nodes, it will actively initiate a block download Request to ensure that the block height of this node is consistent with other nodes.
存储模块215包括storage和state两部分,storage(如AMDB、LevelDB)采用表式存储结构,主要用来存储区块信息、系统表等;state则存储了交易执行结果,包括mpt state和storage state,mpt state是一棵世界状态树,可追溯任何一笔交易的历史信息,storage state存储交易执行后的当前状态,不保存历史信息。The storage module 215 includes two parts: storage and state. Storage (such as AMDB, LevelDB) uses a table-like storage structure, which is mainly used to store block information, system tables, etc.; state stores transaction execution results, including mpt state and storage state, mpt state is a world state tree, which can trace the historical information of any transaction, storage state stores the current state after the transaction is executed, and does not store historical information.
基于上述描述,图3示例性的示出了本发明实施例提供的一种区块链中交易处理的方法的流程,该流程可以由区块链中交易处理的装置执行。Based on the foregoing description, FIG. 3 exemplarily shows a flow of a method for processing transactions in a blockchain provided by an embodiment of the present invention, and the flow may be executed by a device for processing transactions in the blockchain.
如图3所示,该流程具体包括:As shown in Figure 3, the process specifically includes:
步骤301,交易节点接收客户端发送的待处理交易。Step 301: The transaction node receives the pending transaction sent by the client.
客户端发送待处理交易,该待处理交易中可以包括第一随机数,该第一随机数即客户端针对该待处理交易随机生成的随机数值(Nonce值)。可选的,客户端可引入任何随机变量,以生成随机数值,客户端可以采用一个u256类型的随机数。相比于现有技术,客户端无需生成严格递增的序列值,对客户端的业务逻辑要求降低,且在一个账户对应多个客户端时,多个客户端在发送交易时生成相同随机数的概率也非常小,进一步的,为解决客户端生成相同随机数的问题,则需要对客户端发送的待处理交易进行第一验证。The client sends a transaction to be processed, and the transaction to be processed may include a first random number, which is a random value (Nonce value) randomly generated by the client for the transaction to be processed. Optionally, the client can introduce any random variable to generate a random value, and the client can use a random number of type u256. Compared with the prior art, the client does not need to generate strictly increasing sequence values, and the business logic requirements of the client are reduced, and when an account corresponds to multiple clients, the probability that multiple clients generate the same random number when sending transactions It is also very small. Further, in order to solve the problem of the client generating the same random number, the first verification of the pending transaction sent by the client is required.
步骤302,所述交易节点对所述待处理交易进行第一验证。Step 302: The transaction node performs first verification on the transaction to be processed.
交易节点对待处理交易进行第一验证,具体可以为验证该待验证交易中的第一随机数, 判断该第一随机数是否已经记录在随机数记录中,即相当于判断随机数记录中是否包括该第一随机数。此处,随机数记录用于记录已通过第一验证的各交易的随机数,也就是说,判断某笔待处理交易中的第一随机数是否在随机数记录中,若否,则确定该笔待处理交易通过第一验证,并将该笔待处理交易的第一随机数添加至在随机数记录中。The transaction node performs the first verification of the transaction to be processed. Specifically, it can be to verify the first random number in the transaction to be verified, and determine whether the first random number has been recorded in the random number record, which is equivalent to judging whether the random number record includes The first random number. Here, the random number record is used to record the random number of each transaction that has passed the first verification, that is, to determine whether the first random number in a transaction to be processed is in the random number record, if not, determine the The transaction to be processed passes the first verification, and the first random number of the transaction to be processed is added to the random number record.
本发明实施例中,随机数记录可以包括第一随机数记录和第二随机数记录,其中,第一随机数记录用于记录已通过第一验证但未进行上链处理的各交易的随机数;第二随机数记录用于记录已进行上链处理的各交易的随机数。也就是说,交易节点对待处理交易进行第一验证,可以包括两次验证,其一,确定第一随机数记录中不存在第一随机数,其二,确定第二随机数记录中不存在第一随机数。In the embodiment of the present invention, the random number record may include a first random number record and a second random number record, where the first random number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain. ; The second random number record is used to record the random number of each transaction that has been processed on the chain. That is, the transaction node performs the first verification of the transaction to be processed, which may include two verifications. One is to determine that the first random number does not exist in the first random number record, and the other is to determine that the second random number record does not exist. A random number.
可选的,在确定第一随机数记录中不存在第一随机数之后,获取第二随机数记录,并确定该第二随机数记录中是否存在第一随机数。在某些实施例中,该第一随机数记录可以为一个随机数列表,存储于内存中,又可以叫做交易池Nonce列表,用于防止交易池处理重复交易;该第二随机数记录也可以为一个随机数列表,存储于数据库中,又可以叫做Nonce系统表列表,用于防止共识线程打包处理重复交易。Optionally, after determining that the first random number does not exist in the first random number record, obtain a second random number record, and determine whether the first random number exists in the second random number record. In some embodiments, the first random number record may be a random number list stored in memory, and it may also be called a transaction pool Nonce list, which is used to prevent the transaction pool from processing repeated transactions; the second random number record may also It is a list of random numbers, stored in the database, and can also be called a list of Nonce system tables to prevent the consensus thread from packaging and processing repeated transactions.
在获取第二随机数记录时,可以根据区块链的当前区块以及当前区块之前的N个区块获取,假设区块链的当前区块的区块高度为M,则获取区块高度为M至M-N的N个区块中所有交易的随机数,设确定出的交易为第二交易,则确定的交易的随机数即为第二交易的随机数,将该所有的第二交易的随机数记录于第二随机数记录。此处,M和N均为正整数,且M大于N。When obtaining the second random number record, it can be obtained according to the current block of the blockchain and the N blocks before the current block. If the block height of the current block of the blockchain is M, then the block height is obtained Is the random number of all transactions in the N blocks from M to MN. If the determined transaction is the second transaction, then the random number of the determined transaction is the random number of the second transaction. The random number is recorded in the second random number record. Here, both M and N are positive integers, and M is greater than N.
本发明实施例中,N可以理解为交易防重限制(Limit)值,即表示交易防重的区块范围,从当前区块至未来的N个区块内不能存在有重复随机数的交易。当前区块至未来的第N个区块理解为交易防重上限(BlockLimit),即用于表示防重上限的区块高度,假设当前区块为M,则M+N即为交易防重上限的区块高度,其中,N可以根据经验设定,可以设定为1000。进一步的,在获取第二随机数记录时,获取的N个区块中的所有第二交易的随机数是不重复的。In the embodiment of the present invention, N can be understood as the limit value of the transaction weight prevention (Limit) value, that is, the block range of the transaction weight prevention. From the current block to the future N blocks, there cannot be transactions with repeated random numbers. The current block to the Nth block in the future is understood as the upper limit of the transaction weight (BlockLimit), which is the block height used to indicate the upper limit of the weight. Assuming the current block is M, then M+N is the upper limit of the transaction weight The height of the block, where N can be set based on experience and can be set to 1000. Further, when obtaining the second random number record, the obtained random numbers of all the second transactions in the N blocks are not repeated.
此外,客户端发送的待处理交易中还可以包括高度参数,该高度参数用于指示待处理交易所在区块的区块高度不大于高度参数,相应的,交易节点对待处理交易进行第一验证,不仅可以包括判断随机数记录中是否包括该第一随机数,还可以包括,根据区块链的当前区块的区块高度,判断待处理交易中的高度参数是否有效,示例性的,若确定高度参数不小于区块链的当前区块的区块高度且不大于当前区块的区块高度与预设值的加和,则确定该高度参数有效,举例来说,如当前区块高度为1500,预设值为1000,而客户端发送的待处理交易中的高度参数为1700,则确定1700不小于1500且不大于2500,则该高度参数为1700是有效的。该技术方案中,预设值可以根据经验确定,也可以是交易防重限制值。此外,高度参数用于指示客户端发送的待处理交易的优先级,以满足客户端发送交易的不同需求。In addition, the pending transaction sent by the client may also include a height parameter, which is used to indicate that the block height of the transaction to be processed in the block is not greater than the height parameter. Accordingly, the transaction node performs the first verification of the transaction to be processed , Can include not only judging whether the first random number is included in the random number record, but also judging whether the height parameter in the transaction to be processed is valid according to the block height of the current block of the blockchain. For example, if Confirm that the height parameter is not less than the block height of the current block of the blockchain and is not greater than the sum of the block height of the current block and the preset value, then the height parameter is determined to be valid, for example, such as the current block height It is 1500, the default value is 1000, and the height parameter in the transaction to be processed sent by the client is 1700, then it is determined that 1700 is not less than 1500 and not more than 2500, then the height parameter is 1700 is valid. In this technical solution, the preset value can be determined based on experience, or it can be a transaction weight prevention limit value. In addition, the height parameter is used to indicate the priority of pending transactions sent by the client to meet the different needs of the client for sending transactions.
步骤303,所述交易节点确定所述待处理交易通过所述第一验证后,将所述第一随机数记录于所述随机数记录中并将所述待处理交易放入交易池中。Step 303: After determining that the transaction to be processed passes the first verification, the transaction node records the first random number in the random number record and puts the transaction to be processed into a transaction pool.
在交易节点确定待处理交易通过第一验证后,即确定第一随机数记录中不存在第一随机数且确定第二随机数记录中不存在第一随机数后,则可以将该待处理交易放入交易池中,并之后对该交易池中交易进行上链处理,具体的,可以将交易池中的待处理交易打包成区 块,然后对区块进行共识上链。在将交易池中的待处理交易进行上链处理之后,可以将第一随机数从第一随机数记录中删除,以及将第一随机数、待处理交易所在区块的区块高度对应添加至第二随机数记录中。此处,待处理交易所在区块的区块高度理解为,该待处理交易被打包至区块后,区块上链时所在区块链的区块高度。After the transaction node determines that the transaction to be processed passes the first verification, that is, it is determined that the first random number does not exist in the first random number record and the first random number does not exist in the second random number record, the transaction to be processed can be Put it in the transaction pool, and then process the transactions in the transaction pool on the chain. Specifically, the pending transactions in the transaction pool can be packaged into blocks, and then the blocks can be chained by consensus. After the pending transactions in the transaction pool are processed on the chain, the first random number can be deleted from the first random number record, and the first random number and the pending transaction can be added correspondingly to the block height of the block To the second random number record. Here, the block height of the transaction to be processed in the block is understood as the block height of the block chain where the transaction to be processed is packaged into the block when the block is chained.
为了更好的解释本发明实施例,下面将在具体的实施场景下描述该区块链中交易处理的流程,结合图2所示,具体如下:In order to better explain the embodiments of the present invention, the following will describe the transaction processing flow in the blockchain in a specific implementation scenario, which is shown in conjunction with Figure 2, and the details are as follows:
客户端向交易节点发送待处理交易,待处理交易中记录有第一随机数,设待处理交易为T i,且该待处理交易T i的第一随机数为Nonce i;交易节点在接收到T i后,调用交易池中的交易验证器验证T i的有效性,主要包括三方面验证: The client sends the transaction to be processed to the transaction node. The transaction to be processed has the first random number recorded, and the transaction to be processed is T i , and the first random number of the transaction to be processed T i is Nonce i ; the transaction node receives after T i, call transaction transaction validator pool verify the validity of T i, including three verification:
①T i中包含的高度参数是否有效; Height parameter contained in ①T i is valid;
②T i是否重复:首先查询交易池Nonce列表,若Nonce i存在于交易池Nonce列表中,则说明交易池接收过相同的交易,拒绝T i;否则,继续查询Nonce系统表列表,判断T i是否是已上链的交易,若Nonce i存在于Nonce系统表列表中,说明相同交易已经上链,拒绝T i② Whether T i is duplicated: first query the Nonce list of the transaction pool. If Nonce i exists in the Nonce list of the transaction pool, it means that the transaction pool has received the same transaction and rejected T i ; otherwise, continue to query the Nonce system table list to determine whether T i is available on the transaction chain, if Nonce Nonce system table I present in the list, the transaction has been described on the same chain, reject T i;
③T i的签名是否有效。 ③T i signature is valid.
若确定T i通过交易验证器的上述三方面验证,则确定T i可以进行上链处理,且将T i确定为验证通过的交易,具体的,将T i的随机数Nonce i插入到交易池Nonce列表中,以及通过共识模块从交易池中取出T i并打包成区块,在区块共识成功后,将区块通过区块链接口模块提交到存储模块,即将区块上链。在将区块上链成功后,首先更新Nonce系统表列表,将区块的Nonce i追加到Nonce系统表列表,然后再更新交易池Nonce列表,将Nonce i从交易池Nonce列表中删除。 If it is determined that T i passes the above three verifications of the transaction validator, it is determined that T i can be processed on the chain, and T i is determined to be a verified transaction. Specifically, the random number Nonce i of T i is inserted into the transaction pool Nonce list, and remove the module from the transaction by consensus pool T i and packaged into blocks, block after consensus is successful, will be submitted to the storage module block by block link interface module, about to block the chain. After successfully uploading the block to the chain, first update the Nonce system table list, append the Nonce i of the block to the Nonce system table list, and then update the transaction pool Nonce list, and delete Nonce i from the transaction pool Nonce list.
需要说明的是,客户端生成的第一随机数唯一代表一笔交易,本发明实施例中,将Nonce i插入到交易池Nonce列表中,当有第二笔随机数为Nonce i的待处理交易再次提交到交易节点时,交易节点会因交易池Nonce列表中已经存在该Nonce i而拒绝该第二笔待处理交易。以及将Nonce i追加到Nonce系统表列表后,从交易池Nonce列表中删除Nonce i,当有第二笔随机数为Nonce i的待处理交易再次提交到交易节点时,交易节点会因Nonce系统表列表中已经存在该Nonce i而拒绝该第二笔待处理交易。 It should be noted that the first random number generated by the client uniquely represents a transaction. In the embodiment of the present invention, Nonce i is inserted into the Nonce list of the transaction pool. When there is a second pending transaction with the random number Nonce i When submitting to the transaction node again, the transaction node will reject the second pending transaction because the Nonce i already exists in the Nonce list of the transaction pool. And after adding Nonce i to the Nonce system table list, delete Nonce i from the Nonce list of the transaction pool. When a second pending transaction with a random number of Nonce i is submitted to the transaction node again, the transaction node will be affected by the Nonce system table. The Nonce i already exists in the list and the second pending transaction is rejected.
进一步的,在将交易池中已通过验证的交易打包至区块时,可以是共识模块定时从交易池中打包多个已通过验证的交易,也就是说,将区块上链成功后,新区块中存在多个上链交易,该多个上链交易中的第一随机数组成一个Nonce列表,将Nonce列表中的所有第一随机数从交易池Nonce列表中删除,以及追加到Nonce系统表列表中。Further, when packaging the verified transactions in the transaction pool into a block, the consensus module can periodically package multiple verified transactions from the transaction pool, that is, after the block is successfully uploaded to the chain, the new area There are multiple on-chain transactions in the block, and the first random numbers in the multiple on-chain transactions form a Nonce list. All the first random numbers in the Nonce list are deleted from the Nonce list of the transaction pool and added to the Nonce system table. List.
上述技术方案中,客户端无需生成严格递增的序列值,对客户端的业务逻辑要求降低,且在一个账户对应多个客户端时,多个客户端在同时发送交易时生成相同随机数的概率也非常小,进一步的,为解决客户端生成相同随机数的问题,则对客户端发送的待处理交易进行第一验证,在交易节点中设置随机数记录,用于在交易节点接收到待处理交易时,验证待处理交易中的第一随机数是否已经存在于随机数记录中,若否,则确定该待处理交易通过验证,并进一步将该待处理交易的第一随机数记录于随机数记录中,以及将该待处理交易进行上链处理,交易节点无需将接收到的交易放在交易池中等待其他交易处理完成后才处理该笔交易,提高了交易节点处理交易的效率,且保障交易节点不会处理重复交易。In the above technical solution, the client does not need to generate strictly increasing sequence values, and the business logic requirements of the client are reduced, and when one account corresponds to multiple clients, the probability of multiple clients generating the same random number when sending transactions at the same time is also Very small, and further, in order to solve the problem of the client generating the same random number, the first verification is performed on the pending transaction sent by the client, and the random number record is set in the transaction node to receive the pending transaction at the transaction node When, verify whether the first random number in the transaction to be processed already exists in the random number record, if not, determine that the transaction to be processed passes the verification, and further record the first random number of the transaction to be processed in the random number record The transaction node does not need to put the received transaction in the transaction pool and wait for the completion of other transaction processing before processing the transaction, and the pending transaction is processed on the chain, which improves the efficiency of transaction processing by the transaction node and guarantees the transaction The node will not process duplicate transactions.
基于同一发明构思,图4示例性的示出了本发明实施例提供的一种区块链中交易处理 的装置的结构,该装置可以执行区块链中交易处理的方法的流程。该装置,包括:Based on the same inventive concept, FIG. 4 exemplarily shows the structure of a device for processing transactions in a blockchain according to an embodiment of the present invention, and the device can execute the flow of the method for processing transactions in the blockchain. The device includes:
接收单元401,用于接收客户端发送的待处理交易,所述待处理交易包括所述客户端为所述待处理交易随机生成的第一随机数;The receiving unit 401 is configured to receive a pending transaction sent by a client, where the pending transaction includes a first random number randomly generated by the client for the pending transaction;
处理单元402,用于对所述待处理交易进行第一验证;其中,所述第一验证包括确定随机数记录中是否包括所述第一随机数;所述随机数记录用于记录已通过所述第一验证的各交易的随机数;以及确定所述待处理交易通过所述第一验证后,将所述第一随机数记录于所述随机数记录中并将所述待处理交易放入交易池中。The processing unit 402 is configured to perform a first verification on the pending transaction; wherein the first verification includes determining whether the first random number is included in a random number record; the random number record is used to record that the transaction has passed The random number of each transaction of the first verification; and after determining that the transaction to be processed passes the first verification, record the first random number in the random number record and place the transaction to be processed In the trading pool.
可选的,所述随机数记录包括第一随机数记录和第二随机数记录;Optionally, the random number record includes a first random number record and a second random number record;
所述第一随机数记录用于记录已通过所述第一验证但未进行上链处理的各交易的随机数;The first random number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain;
所述第二随机数记录用于记录已进行所述上链处理的各交易的随机数;The second random number record is used to record the random number of each transaction that has been processed on the chain;
所述处理单元402具体用于:The processing unit 402 is specifically configured to:
确定所述第一随机数记录中不存在所述第一随机数后,确定所述第二随机数记录中不存在所述第一随机数。After determining that the first random number does not exist in the first random number record, it is determined that the first random number does not exist in the second random number record.
可选的,所述第二随机数记录包括第二交易的随机数;所述第二交易是区块高度为M至M-N的N个区块中记录的交易,其中,M为区块链的当前区块的区块高度,M和N均为正整数,且M大于N。Optionally, the second random number record includes the random number of the second transaction; the second transaction is a transaction recorded in N blocks with a block height of M to MN, where M is a block chain The block height of the current block, M and N are both positive integers, and M is greater than N.
可选的,所述处理单元402还用于:Optionally, the processing unit 402 is further configured to:
在所述在将所述待处理交易放入交易池中之后,将所述交易池中的待处理交易打包成区块并对所述区块进行共识上链;After placing the pending transaction in the transaction pool, package the pending transaction in the transaction pool into a block, and perform a consensus upload on the block;
将所述第一随机数从所述第一随机数记录中删除,并将所述第一随机数、所述待处理交易所在区块的区块高度对应添加至所述第二随机数记录中。Delete the first random number from the first random number record, and add the first random number and the block height of the transaction to be processed to the second random number record correspondingly in.
基于与上述图3所示的方法相同的构思,本申请还提供一种计算设备,如图5所示,该计算设备包括至少一个处理器520,用于实现本申请实施例提供的图3中任一方法。Based on the same concept as the method shown in FIG. 3, the present application also provides a computing device. As shown in FIG. 5, the computing device includes at least one processor 520 for implementing the method in FIG. 3 provided by the embodiment of the present application. Any method.
计算设备500还可以包括至少一个存储器530,用于存储程序指令和/或数据。存储器530和处理器520耦合。本申请实施例中的耦合是装置、单元或模块之间的间接耦合或通信连接,可以是电性,机械或其它的形式,用于装置、单元或模块之间的信息交互。处理器520可能和存储器530协同操作。处理器520可能执行存储器530中存储的程序指令。所述至少一个存储器中的至少一个可以包括于处理器中。The computing device 500 may also include at least one memory 530 for storing program instructions and/or data. The memory 530 and the processor 520 are coupled. The coupling in the embodiments of the present application is an indirect coupling or communication connection between devices, units, or modules, and may be in electrical, mechanical or other forms, and is used for information exchange between devices, units or modules. The processor 520 may cooperate with the memory 530 to operate. The processor 520 may execute program instructions stored in the memory 530. At least one of the at least one memory may be included in the processor.
在实现过程中,上述方法的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。结合本申请实施例所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。为避免重复,这里不再详细描述。In the implementation process, the steps of the above method can be completed by hardware integrated logic circuits in the processor or instructions in the form of software. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware processor, or executed and completed by a combination of hardware and software modules in the processor. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware. To avoid repetition, it will not be described in detail here.
应注意,本申请实施例中的处理器可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法实施例的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器可以是通用处理器、数字信号处理电路(digital signal processor,DSP)、专用集成芯片(application specific integrated circuit,ASIC)、现场可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者 晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。It should be noted that the processor in the embodiment of the present application may be an integrated circuit chip with signal processing capability. In the implementation process, the steps of the foregoing method embodiments can be completed by hardware integrated logic circuits in the processor or instructions in the form of software. The above-mentioned processor may be a general-purpose processor, a digital signal processing circuit (digital signal processor, DSP), a dedicated integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field programmable gate array, FPGA) or other Programming logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps, and logical block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
可以理解,本申请实施例中的存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(dynamic RAM,DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。应注意,本文描述的系统和方法的存储器旨在包括但不限于这些和任意其它适合类型的存储器。It can be understood that the memory in the embodiment of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), and electronic Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory. The volatile memory may be random access memory (RAM), which is used as an external cache. By way of exemplary but not restrictive description, many forms of RAM are available, such as static random access memory (static RAM, SRAM), dynamic random access memory (dynamic RAM, DRAM), synchronous dynamic random access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous connection dynamic random access memory (synchlink DRAM, SLDRAM) ) And direct memory bus random access memory (direct rambus RAM, DR RAM). It should be noted that the memories of the systems and methods described herein are intended to include, but are not limited to, these and any other suitable types of memories.
计算设备500还可以包括通信接口510,用于通过传输介质和其它设备进行通信,从而用于计算设备500中的装置可以和其它设备进行通信。在本申请实施例中,通信接口可以是收发器、电路、总线、模块或其它类型的通信接口。在本申请实施例中,通信接口为收发器时,收发器可以包括独立的接收器、独立的发射器;也可以集成收发功能的收发器、或者是接口电路。The computing device 500 may further include a communication interface 510 for communicating with other devices through a transmission medium, so that the apparatus used in the computing device 500 can communicate with other devices. In the embodiment of the present application, the communication interface may be a transceiver, circuit, bus, module, or other type of communication interface. In the embodiments of the present application, when the communication interface is a transceiver, the transceiver may include an independent receiver and an independent transmitter; it may also be a transceiver with integrated transceiver functions, or an interface circuit.
计算设备500还可以包括通信线路540。其中,通信接口510、处理器520以及存储器530可以通过通信线路540相互连接;通信线路540可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。所述通信线路540可以分为地址总线、数据总线、控制总线等。为便于表示,图5中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The computing device 500 may also include a communication line 540. Among them, the communication interface 510, the processor 520, and the memory 530 may be connected to each other through a communication line 540; the communication line 540 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (extended industry standard architecture). , Referred to as EISA) bus and so on. The communication line 540 can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one thick line is used in FIG. 5 to represent, but it does not mean that there is only one bus or one type of bus.
基于同一发明构思,本发明实施例还提供了一种计算机可读非易失性存储介质,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行上述区块链中交易处理的方法。Based on the same inventive concept, embodiments of the present invention also provide a computer-readable non-volatile storage medium, including computer-readable instructions. When the computer reads and executes the computer-readable instructions, the computer executes the aforementioned blocks. The method of transaction processing in the chain.
基于同一发明构思,本申请实施例提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述区块链中交易处理的方法。Based on the same inventive concept, the embodiments of the present application provide a computer program product containing instructions, which when running on a computer, cause the computer to execute the above-mentioned method of transaction processing in the blockchain.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用 于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowcharts and/or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and/or block in the flowchart and/or block diagram, and the combination of processes and/or blocks in the flowchart and/or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are generated It is a device that realizes the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device. The device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment. The instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present invention.
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. In this way, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.

Claims (11)

  1. 一种区块链中交易处理的方法,其特征在于,包括:A method for transaction processing in a blockchain, characterized in that it includes:
    交易节点接收客户端发送的待处理交易,所述待处理交易包括所述客户端为所述待处理交易随机生成的第一随机数;The transaction node receives the pending transaction sent by the client, where the pending transaction includes a first random number randomly generated by the client for the pending transaction;
    所述交易节点对所述待处理交易进行第一验证;其中,所述第一验证包括确定随机数记录中是否包括所述第一随机数;所述随机数记录用于记录已通过所述第一验证的各交易的随机数;The transaction node performs a first verification on the pending transaction; wherein, the first verification includes determining whether the first random number is included in a random number record; the random number record is used to record that the first random number has been passed 1. The random number of each transaction verified;
    所述交易节点确定所述待处理交易通过所述第一验证后,将所述第一随机数记录于所述随机数记录中并将所述待处理交易放入交易池中。After determining that the transaction to be processed passes the first verification, the transaction node records the first random number in the random number record and puts the transaction to be processed into a transaction pool.
  2. 如权利要求1所述的方法,其特征在于,所述随机数记录包括第一随机数记录和第二随机数记录;8. The method of claim 1, wherein the random number record comprises a first random number record and a second random number record;
    所述第一随机数记录用于记录已通过所述第一验证但未进行上链处理的各交易的随机数;The first random number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain;
    所述第二随机数记录用于记录已进行所述上链处理的各交易的随机数;The second random number record is used to record the random number of each transaction that has been processed on the chain;
    所述交易节点确定所述待处理交易通过所述第一验证,包括:The determining by the transaction node that the transaction to be processed passes the first verification includes:
    确定所述第一随机数记录中不存在所述第一随机数后,确定所述第二随机数记录中不存在所述第一随机数。After determining that the first random number does not exist in the first random number record, it is determined that the first random number does not exist in the second random number record.
  3. 如权利要求2所述的方法,其特征在于,所述第二随机数记录包括第二交易的随机数;所述第二交易是区块高度为M至M-N的N个区块中记录的交易,其中,M为区块链的当前区块的区块高度,M和N均为正整数,且M大于N。The method of claim 2, wherein the second random number record includes a random number of a second transaction; the second transaction is a transaction recorded in N blocks with a block height of M to MN , Where M is the block height of the current block of the blockchain, M and N are both positive integers, and M is greater than N.
  4. 如权利要求2所述的方法,其特征在于,所述交易节点在将所述待处理交易放入交易池中之后,还包括:The method according to claim 2, wherein after the transaction node puts the transaction to be processed into the transaction pool, the method further comprises:
    将所述交易池中的待处理交易打包成区块并对所述区块进行共识上链;Package the pending transactions in the transaction pool into blocks and perform consensus on the blocks on the chain;
    将所述第一随机数从所述第一随机数记录中删除,并将所述第一随机数、所述待处理交易所在区块的区块高度对应添加至所述第二随机数记录中。Delete the first random number from the first random number record, and add the first random number and the block height of the transaction to be processed to the second random number record correspondingly in.
  5. 一种区块链中交易处理的装置,其特征在于,包括:A device for processing transactions in a blockchain, characterized in that it comprises:
    接收单元,用于接收客户端发送的待处理交易,所述待处理交易包括所述客户端为所述待处理交易随机生成的第一随机数;A receiving unit, configured to receive a pending transaction sent by a client, where the pending transaction includes a first random number randomly generated by the client for the pending transaction;
    处理单元,用于对所述待处理交易进行第一验证;其中,所述第一验证包括确定随机数记录中是否包括所述第一随机数;所述随机数记录用于记录已通过所述第一验证的各交易的随机数;以及确定所述待处理交易通过所述第一验证后,将所述第一随机数记录于所述随机数记录中并将所述待处理交易放入交易池中。The processing unit is configured to perform first verification on the pending transaction; wherein the first verification includes determining whether the first random number is included in the random number record; the random number record is used to record that the transaction has passed the The random number of each transaction of the first verification; and after determining that the transaction to be processed passes the first verification, record the first random number in the random number record and put the transaction to be processed into the transaction In the pool.
  6. 如权利要求5所述的装置,其特征在于,所述随机数记录包括第一随机数记录和第二随机数记录;5. The device of claim 5, wherein the random number record comprises a first random number record and a second random number record;
    所述第一随机数记录用于记录已通过所述第一验证但未进行上链处理的各交易的随机数;The first random number record is used to record the random number of each transaction that has passed the first verification but has not been processed on the chain;
    所述第二随机数记录用于记录已进行所述上链处理的各交易的随机数;The second random number record is used to record the random number of each transaction that has been processed on the chain;
    所述处理单元具体用于:The processing unit is specifically used for:
    确定所述第一随机数记录中不存在所述第一随机数后,确定所述第二随机数记录中不 存在所述第一随机数。After determining that the first random number does not exist in the first random number record, it is determined that the first random number does not exist in the second random number record.
  7. 如权利要求6所述的装置,其特征在于,所述第二随机数记录包括第二交易的随机数;所述第二交易是区块高度为M至M-N的N个区块中记录的交易,其中,M为区块链的当前区块的区块高度,M和N均为正整数,且M大于N。7. The device of claim 6, wherein the second random number record includes a random number of a second transaction; the second transaction is a transaction recorded in N blocks with a block height of M to MN , Where M is the block height of the current block of the blockchain, M and N are both positive integers, and M is greater than N.
  8. 如权利要求6所述的装置,其特征在于,所述处理单元还用于:The device according to claim 6, wherein the processing unit is further configured to:
    在所述在将所述待处理交易放入交易池中之后,将所述交易池中的待处理交易打包成区块并对所述区块进行共识上链;After placing the pending transaction in the transaction pool, package the pending transaction in the transaction pool into a block, and perform a consensus upload on the block;
    将所述第一随机数从所述第一随机数记录中删除,并将所述第一随机数、所述待处理交易所在区块的区块高度对应添加至所述第二随机数记录中。Delete the first random number from the first random number record, and add the first random number and the block height of the transaction to be processed to the second random number record correspondingly in.
  9. 一种计算设备,其特征在于,包括:A computing device, characterized by comprising:
    存储器,用于存储程序指令;Memory, used to store program instructions;
    处理器,用于调用所述存储器中存储的程序指令,按照获得的程序执行权利要求1至4任一项所述的方法。The processor is configured to call the program instructions stored in the memory, and execute the method according to any one of claims 1 to 4 according to the obtained program.
  10. 一种计算机可读非易失性存储介质,其特征在于,包括计算机可读指令,当计算机读取并执行所述计算机可读指令时,使得计算机执行如权利要求1至4任一项所述的方法。A computer-readable non-volatile storage medium, characterized by comprising computer-readable instructions, when the computer reads and executes the computer-readable instructions, the computer is caused to execute any one of claims 1 to 4 Methods.
  11. 一种计算机程序产品,其特征在于,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行权利要求1至4任一所述方法。A computer program product, characterized in that, the computer program product includes a calculation program stored on a non-transitory computer-readable storage medium, the computer program includes program instructions, when the program instructions are executed by a computer, The computer executes the method described in any one of claims 1 to 4.
PCT/CN2020/095201 2019-06-14 2020-06-09 Method and device for transaction processing in blockchain WO2020248982A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910514704.3A CN110276688B (en) 2019-06-14 2019-06-14 Method and device for processing transactions in blockchain
CN201910514704.3 2019-06-14

Publications (1)

Publication Number Publication Date
WO2020248982A1 true WO2020248982A1 (en) 2020-12-17

Family

ID=67960793

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/095201 WO2020248982A1 (en) 2019-06-14 2020-06-09 Method and device for transaction processing in blockchain

Country Status (2)

Country Link
CN (1) CN110276688B (en)
WO (1) WO2020248982A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110276688B (en) * 2019-06-14 2024-02-06 深圳前海微众银行股份有限公司 Method and device for processing transactions in blockchain
CN110796545B (en) * 2019-10-25 2024-03-29 杭州趣链科技有限公司 Block chain transaction batch processing method, equipment and storage medium
CN111639129B (en) * 2020-05-24 2023-07-11 中信银行股份有限公司 Transaction processing method, device, electronic equipment and computer readable storage medium
CN112926981B (en) * 2021-03-18 2022-10-28 腾讯科技(深圳)有限公司 Transaction information processing method, device and medium for block chain and electronic equipment
CN113630475A (en) * 2021-09-17 2021-11-09 无锡井通网络科技有限公司 Block chain system cluster based on interfacing block chain system and operation method thereof

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106991607A (en) * 2017-03-29 2017-07-28 杭州秘猿科技有限公司 A kind of unordered transaction control method based on block chain account model
CN108764870A (en) * 2018-05-29 2018-11-06 阿里巴巴集团控股有限公司 Transaction processing method and device, electronic equipment based on block chain
CN108805569A (en) * 2018-05-29 2018-11-13 阿里巴巴集团控股有限公司 Transaction processing method and device, electronic equipment based on block chain
CN109064171A (en) * 2018-07-26 2018-12-21 杭州秘猿科技有限公司 A kind of method, apparatus and electronic system of block chain parallel transaction
WO2019072314A2 (en) * 2018-12-29 2019-04-18 Alibaba Group Holding Limited System and method for detecting replay attack
CN110276688A (en) * 2019-06-14 2019-09-24 深圳前海微众银行股份有限公司 The method and device of trading processing in a kind of block chain

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108985757B (en) * 2017-11-27 2021-03-30 京东数字科技控股有限公司 Information processing method, device and system, storage medium and electronic equipment
CN109285006A (en) * 2018-09-20 2019-01-29 中链科技有限公司 A kind of parallel proof processing method and processing device of block chain data
CN109327459B (en) * 2018-11-12 2020-12-01 崔晓晖 Consensus method for union block chain network
CN109727009B (en) * 2019-01-28 2023-11-24 杭州复杂美科技有限公司 Red packet processing method, apparatus and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106991607A (en) * 2017-03-29 2017-07-28 杭州秘猿科技有限公司 A kind of unordered transaction control method based on block chain account model
CN108764870A (en) * 2018-05-29 2018-11-06 阿里巴巴集团控股有限公司 Transaction processing method and device, electronic equipment based on block chain
CN108805569A (en) * 2018-05-29 2018-11-13 阿里巴巴集团控股有限公司 Transaction processing method and device, electronic equipment based on block chain
CN109064171A (en) * 2018-07-26 2018-12-21 杭州秘猿科技有限公司 A kind of method, apparatus and electronic system of block chain parallel transaction
WO2019072314A2 (en) * 2018-12-29 2019-04-18 Alibaba Group Holding Limited System and method for detecting replay attack
CN110276688A (en) * 2019-06-14 2019-09-24 深圳前海微众银行股份有限公司 The method and device of trading processing in a kind of block chain

Also Published As

Publication number Publication date
CN110276688A (en) 2019-09-24
CN110276688B (en) 2024-02-06

Similar Documents

Publication Publication Date Title
WO2020248982A1 (en) Method and device for transaction processing in blockchain
WO2021068728A1 (en) Methods and apparatus for generating state tree of block and validating on-chain data
WO2021077962A1 (en) Method and apparatus for blockchain node synchronization
WO2021036702A1 (en) Consensus method and device employing blockchain system
CN108182581B (en) Accounting method and device for block chain
CN109636144B (en) Block chain risk assessment supply chain financial method, device, equipment and storage medium
WO2021027531A1 (en) Block chain transaction record processing method and device
WO2020015533A1 (en) Transaction processing method and apparatus, and blockchain system
TW201909613A (en) Method, device and electronic device for processing consensus request in blockchain consensus network
WO2021109809A1 (en) Cross-chain transaction method and device
WO2021120925A1 (en) Block synchronization method and device
WO2020220860A1 (en) Blockchain system-based transaction processing method and apparatus
US20210049715A1 (en) Blockchain-based data procesing method, apparatus, and electronic device
WO2021027530A1 (en) Data processing method and device based on block chain
US10999283B2 (en) Addressing transaction conflict in blockchain systems
CN113076376B (en) Multi-party asynchronous sampling consensus method, system and device based on block chain and medium
CN106649788A (en) Database data transmission method and device
US20200026427A1 (en) System and method for handling data storage on storage devices
WO2021129004A1 (en) Blockchain data access control method and apparatus based on intelligent contract
WO2020228365A1 (en) Reconciliation method and device employing consortium chain, and electronic apparatus
WO2020177488A1 (en) Method and device for blockchain transaction tracing
WO2020211622A1 (en) Blockchain-based message storage method and device
CN110659905A (en) Transaction verification method, device, terminal equipment and storage medium
CN114297304A (en) Product information block chain transaction storage method, server and readable medium
WO2021115002A1 (en) Method and apparatus for processing blockchain transaction record

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: 20821936

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20821936

Country of ref document: EP

Kind code of ref document: A1