Transaction processing method and device based on block chain, equipment and medium
By decoupling block nodes and proposed nodes in the blockchain network, and being responsible for block generation and transaction execution, the problems of high transaction processing complexity and resource overhead in the blockchain network are solved, and performance improvement is achieved.
Patent Information
- Application Number
- CN202411419633.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-11
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-10-11
AI Technical Summary
When each node in the blockchain network processes transaction data, it needs to perform broadcast and consensus processing, resulting in high communication complexity and large resource overhead, which affects overall performance.
By decoupling the block-producing node and the proposed node from the consensus node, the block-producing node is responsible for generating blocks, and the proposed node is responsible for executing transactions and initiating consensus processing. The node only needs to send transaction information to the block-producing node and no longer broadcast. Reduces communication complexity.
It reduces the communication complexity of the blockchain network, from O(nlgn) to O(n), and reduces the overhead of storage and computing resources, improving the performance of the blockchain network.
Smart Images

Figure CN119417467A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of blockchain technology, and in particular to a transaction processing method, device, equipment, and medium based on blockchain. Background Art
[0002] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain technology is built on the blockchain network, and data transmission and processing are realized through each node in the blockchain network.
[0003] In the related technology, when each node in the blockchain network receives transaction data, it needs to process the transaction data and broadcast the transaction data to other nodes in the blockchain network. At the same time, it is also necessary to update its own transaction pool after the transaction data passes consensus. This increases the complexity of blockchain network communication and also makes the storage and computing resources of the blockchain network expensive, thereby affecting the overall performance of the blockchain network. Summary of the invention
[0004] In order to solve the above technical problems, the embodiments of the present disclosure provide a transaction processing method, device, equipment, and medium based on blockchain.
[0005] One aspect of an embodiment of the present disclosure provides a transaction processing method based on blockchain, which is applied to a blockchain network, wherein the blockchain network includes: a block-producing node, a proposing node and multiple consensus nodes, and the method includes: in response to the block-producing node receiving a block acquisition request sent by the proposing node, the block-producing node deletes the transaction information corresponding to the previous block in the transaction pool corresponding to the block-producing node based on the block information of the previous block in the block acquisition request, so as to update the transaction pool corresponding to the block-producing node; the block-producing node generates a new block based on the transaction information in the transaction pool corresponding to the block-producing node, and sends the new block to the proposing node; the proposing node executes each transaction information in the new block, and writes the transaction result of each transaction information into the new block to obtain a block to be chained; the proposing node initiates consensus processing of the block to be chained in the blockchain network; in response to the block to be chained passing the consensus, the block to be chained is added to the blockchain.
[0006] Another aspect of the embodiments of the present disclosure provides a blockchain-based transaction processing device, which is applied to a blockchain network, wherein the blockchain network includes: a block-generating node, a proposing node, and a plurality of consensus nodes, wherein the device includes: a first transaction pool updating module, which is used for, in response to the block-generating node receiving a block acquisition request sent by the proposing node, the block-generating node deletes the transaction information corresponding to the previous block in the transaction pool corresponding to the block-generating node based on the block information of the previous block in the block acquisition request, so as to update the transaction pool corresponding to the block-generating node; a block generation module, which is used for the block-generating node to generate a new block based on the transaction information in the transaction pool corresponding to the block-generating node, and send the new block to the proposing node; a transaction execution module, which is used for the proposing node to execute each transaction information in the new block, and write the transaction result of each transaction information into the new block to obtain a block to be chained; a consensus module, which is used for the proposing node to initiate consensus processing of the block to be chained in the blockchain network; and a chaining module, which is used for adding the block to be chained to the blockchain in response to the block to be chained passing consensus.
[0007] Another aspect of the embodiments of the present disclosure provides an electronic device, comprising: a memory for storing a computer program; a processor for executing the computer program stored in the memory, and when the computer program is executed, the above-mentioned blockchain-based transaction processing method is implemented.
[0008] Another aspect of the embodiments of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned blockchain-based transaction processing method.
[0009] The transaction processing method, device, equipment, and medium based on blockchain in the disclosed embodiments. When the block-producing node receives the block acquisition request sent by the proposing node, the block-producing node deletes the transaction information corresponding to the previous block in the transaction pool corresponding to the block-producing node based on the block information of the previous block in the block acquisition request, so as to update the transaction pool corresponding to the block-producing node, and then generates a new block based on the transaction information in the transaction pool corresponding to the block-producing node, and sends the new block to the proposing node; the proposing node executes each transaction information in the new block, and writes the transaction result of each transaction information into the new block to obtain the block to be chained; the proposing node initiates consensus processing of the block to be chained in the blockchain network; when the block to be chained passes the consensus, the block to be chained is added to the blockchain. In the disclosed embodiments, by decoupling the block-producing nodes and the proposing nodes from the consensus nodes, since the block-producing nodes are responsible for generating blocks, when the nodes in the blockchain network receive transaction information, they only need to send the transaction information to the block-producing nodes, and there is no need to broadcast it to all the nodes in the blockchain network. This reduces the complexity of blockchain network communication from O(nlgn) to O(n), where n is the number of consensus nodes, thereby greatly reducing the complexity of blockchain network communication.
[0010] In addition, since transaction information is stored in the transaction pool corresponding to the block-producing node and the consensus on the blocks to be on the chain is initiated by the proposing node, the transaction pools of the consensus nodes and proposing nodes in the blockchain network no longer need to store and update transaction information, thereby reducing the storage resource overhead and computing resource overhead of the blockchain network, and thus improving the performance of the blockchain network.
[0011] The technical solution of the present disclosure is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0013] The present disclosure may be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:
[0014] Figure 1 It is a flowchart of a transaction processing method based on blockchain provided by an exemplary embodiment of the present disclosure.
[0015] Figure 2 It is a flowchart of a blockchain-based transaction processing method provided by another exemplary embodiment of the present disclosure.
[0016] Figure 3 It is a flowchart of step S200 provided by an exemplary embodiment of the present disclosure.
[0017] Figure 4 It is a flowchart of a transaction processing method based on blockchain provided by another exemplary embodiment of the present disclosure.
[0018] Figure 5 It is a schematic diagram of a blockchain network provided by an application example of the present disclosure.
[0019] Figure 6 It is a schematic diagram of a blockchain-based transaction processing method provided by an application example of the present disclosure.
[0020] Figure 7 It is a structural block diagram of a blockchain-based transaction processing device provided by an exemplary embodiment of the present disclosure.
[0021] Figure 8 The figure is a schematic diagram of the structure of an application embodiment of the electronic device disclosed in the present invention. DETAILED DESCRIPTION
[0022] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.
[0023] Those skilled in the art can understand that the terms "first" and "second" in the embodiments of the present disclosure are only used to distinguish different steps, devices or modules, etc., and neither represent any specific technical meaning nor indicate the necessary logical order between them.
[0024] It should also be understood that in the embodiments of the present disclosure, “plurality” may refer to two or more than two, and “at least one” may refer to one, two, or more than two.
[0025] It should also be understood that any component, data or structure mentioned in the embodiments of the present disclosure can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.
[0026] In addition, the term "and / or" in the present disclosure is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present disclosure generally indicates that the associated objects before and after are in an "or" relationship.
[0027] It should also be understood that the description of the various embodiments in the present disclosure focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.
[0028] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0029] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.
[0030] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.
[0031] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0032] The embodiments of the present disclosure can be applied to electronic devices such as terminal devices, computer systems, servers, etc., which can operate with many other general or special computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers, etc. include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, etc.
[0033] Electronic devices such as terminal devices, computer systems, servers, etc. can be described in the general context of computer system executable instructions (such as program modules) executed by computer systems. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.
[0034] In the disclosed embodiments:
[0035] A node in a blockchain network usually refers to a computing device in the blockchain network. That is to say, any computing device (including mobile phones, servers, etc.) connected to the blockchain network is called a node. The node can be used to store, run, verify, and process data in the blockchain network.
[0036] Figure 1 is a flowchart of a transaction processing method based on blockchain provided by an exemplary embodiment of the present disclosure. This embodiment can be applied on a blockchain network, such as Figure 1As shown, the transaction processing method based on blockchain may include the following steps:
[0037] Step S100, in response to the block producing node receiving the block acquisition request sent by the proposing node, the block producing node deletes the transaction information corresponding to the previous block in the transaction pool corresponding to the block producing node based on the block information of the previous block in the block acquisition request, so as to update the transaction pool corresponding to the block producing node.
[0038] The blockchain network includes: block nodes, proposal nodes and multiple consensus nodes. The block nodes are used to generate blocks, the proposal nodes are used to request blocks from the block nodes, execute the transaction information in the blocks, initiate consensus on the blocks and reach consensus on the blocks, and the consensus nodes are used to reach consensus on the blocks.
[0039] The block-producing node is connected to the proposal node and multiple consensus nodes respectively, the proposal node is connected to the multiple consensus nodes, and the multiple consensus nodes are connected to each other. The block-producing node includes a transaction pool, which is used to store transaction information. In this embodiment, the transaction pool in the block-producing node can be referred to as the transaction pool corresponding to the block-producing node.
[0040] The previous block is the latest block in the blockchain network, that is, the previous block of the new block. Transaction information is used to represent transaction-related data. Exemplarily, transaction information may include: information of each transaction party and transaction data, etc., wherein the information of the transaction party may include the account identification and address of the transaction party, etc., and the transaction data may include: transaction type, gas fee and transaction time, etc. The transaction types may include, but are not limited to: ticket transactions, car purchase transactions, parking fee transactions, etc.
[0041] The block acquisition request includes: block information of the previous block, for example, the block information of the previous block may include a hash value of the previous block, etc.
[0042] In one embodiment, the block producing node can cache the previous block. When the proposing node determines that the previous block has been added to the blockchain, the proposing node sends a block acquisition request to the block producing node. When the block producing node receives the block acquisition request, the block producing node determines the transaction information corresponding to the previous block in the transaction pool based on the block information of the previous block, and deletes the transaction information corresponding to the previous block to update the transaction pool. The transaction information corresponding to the previous block may be the transaction information included in the previous block.
[0043] Step S110: The block-producing node generates a new block based on the transaction information in the transaction pool corresponding to the block-producing node, and sends the new block to the proposing node.
[0044] Among them, in the transaction pool corresponding to the block-producing node, the remaining transactions after deleting the transaction information corresponding to the previous block are sorted, and a new block is generated based on the sorted remaining transaction information.
[0045] Step S120: The proposing node executes each transaction information in the new block and writes the transaction result of each transaction information into the new block to obtain a block to be chained.
[0046] Among them, the proposing node can execute each transaction information in the new block, and update each transaction information according to the transaction result of each transaction information. For example, the balance of the account in each transaction information can be updated, and then the Merkle root is calculated through the updated transaction information, and the Merkle root is written into the new block to write the transaction result of each transaction information into the new block to obtain the block to be chained.
[0047] Step S130: The proposing node initiates a consensus process for the block to be chained in the blockchain network.
[0048] In one embodiment, the proposing node may send the to-be-chained blocks to multiple consensus nodes, and initiate consensus on the to-be-chained blocks in the blockchain network, and multiple consensus nodes and the proposing node perform consensus processing on the to-be-chained blocks based on a preset consensus algorithm. The preset consensus algorithm may include, for example, Practical Byzantine Fault Tolerance (PBFT), Delegated Proof of Stake (DPOS), or HotStuff consensus, etc.
[0049] Step S140, in response to the block to be chained passing the consensus, the block to be chained is added to the blockchain.
[0050] Among them, when the block to be chained passes the consensus, the block to be chained can be added to the blockchain so that the block to be chained can be chained.
[0051] In one embodiment, when the block to be chained fails to pass the consensus, the block to be chained is not added to the blockchain, that is, the block to be chained fails to be chained.
[0052] In the disclosed embodiment, by decoupling the block-producing node and the proposing node from the consensus node, since the block-producing node is responsible for generating blocks, when the nodes in the blockchain network receive transaction information, they only need to send the transaction information to the block-producing node, and no longer need to send it to all nodes in the blockchain network. This reduces the complexity of blockchain network communication from O(nlgn) to O(n), where n is the number of consensus nodes, thereby greatly reducing the complexity of blockchain network communication. In addition, since the transaction information is stored in the transaction pool corresponding to the block-producing node, and the consensus on the block to be chained is initiated by the proposing node, the transaction pool of the consensus node and the proposing node in the blockchain network no longer needs to store and update the transaction information, thereby reducing the overhead of storage resources and computing resources, thereby improving the performance of the blockchain network.
[0053] In some optional implementations, in the embodiments of the present disclosure, step S130 may include: the proposing node sends the block to be chained to multiple consensus nodes and block-producing nodes, and the multiple consensus nodes, the proposing nodes and the block-producing nodes perform consensus processing on the block to be chained.
[0054] In an optional implementation, the block-producing node can also be used for block consensus. The proposing node initiates consensus on the block to be on the chain to multiple consensus nodes, proposing nodes and block-producing nodes, and multiple consensus nodes, proposing nodes and block-producing nodes reach consensus on the block node to be on the chain based on a preset consensus algorithm.
[0055] Accordingly, in this embodiment, step S140 may also include: multiple consensus nodes, proposal nodes and block production nodes add the blocks to be chained to their respective blockchains.
[0056] In some optional implementations, in the embodiments of the present disclosure, the blockchain-based transaction processing method may also include: for each node in the blockchain network, in response to the consensus height of the node being greater than or equal to a preset number of blocks, the node determines a new block-producing node from other nodes in the blockchain network except the block-producing node.
[0057] The consensus height of a node is used to indicate the number of consensus blocks of the node. The preset number of blocks can be set according to actual needs.
[0058] In one embodiment, in a blockchain network, when the consensus height of a block-producing node, a proposing node, and each of a plurality of consensus nodes is greater than or equal to a preset number of blocks, that is, when the consensus height of each node in the blockchain network is greater than or equal to a preset number of blocks, the block-producing node, the proposing node, and a plurality of consensus nodes respectively determine a new block-producing node from other nodes.
[0059] Exemplarily, the block-producing node, the proposing node and the plurality of consensus nodes may respectively determine a new block-producing node from the plurality of consensus nodes. Wherein, when it is determined that the proposing node is used as the new block-producing node, the new block-producing node serves as both the block-producing node and the proposing node.
[0060] After the new block node is determined, the transaction pool corresponding to the new block node is activated (the transaction pool in the new block node), so that the transaction pool corresponding to the new block node enters the working state to store transaction information, and the new block node is responsible for subsequent block generation, and the transaction pool corresponding to the block node is closed, so that the transaction pool corresponding to the block node is in a non-working state, that is, the transaction information is no longer stored and updated in the future, and the block node is restored to the node before the block node becomes a block node. Exemplarily, when a consensus node is used as a block node, when a new block node is determined, the block node is restored to a consensus node, and when a proposal node is used as a block node, when a new block node is determined, the block node only serves as a proposal node.
[0061] In the disclosed embodiment, when the block height of each node in the blockchain network is greater than or equal to the preset number of blocks, each node in the blockchain network determines a new block node to be responsible for subsequent block generation, thereby increasing the fairness and data security of the blockchain network. In addition, the new block node is selected from the nodes of the blockchain network, so there is no need to add additional new nodes as block nodes in the blockchain network.
[0062] In some optional implementations, in the embodiments of the present disclosure, the node may determine the new block-producing node in the following manner: the node determines the new block-producing node from other nodes based on a preset block-producing node ranking.
[0063] The preset block-producing node order may include the order in which each node in the blockchain network is determined as a block-producing node. In one embodiment, each of the block-producing nodes, the proposing node, and the plurality of consensus nodes may determine a new block-producing node from other nodes according to the preset block-producing node order.
[0064] In the embodiment of the present disclosure, selecting a new block-producing node according to a preset block-producing node ranking can effectively ensure the consistency of the new block-producing node selected by each node in the blockchain network.
[0065] Figure 2 is a flowchart of a transaction processing method based on blockchain provided by another exemplary embodiment of the present disclosure. In some optional implementations, in the embodiment of the present disclosure, the node can also determine the new block node in the following manner:
[0066] Step S200: The node obtains target random information.
[0067] Among them, each of the block-producing node, the proposing node and the multiple consensus nodes obtains the target random information. Exemplarily, when the consensus height of each node in the blockchain network is greater than or equal to the preset number of blocks, a random number can be generated by a random number generator, and the random number can be sent to the block-producing node, the proposing node and the multiple consensus nodes, and each of the block-producing node, the proposing node and the multiple consensus nodes can use the hash value of the random number as the target random information.
[0068] Step S210: The node determines a new block generating node based on the distance between the target random information and the node information of other nodes.
[0069] The node information may include, for example, address information and / or identification of the node.
[0070] In one embodiment, each of the block-producing node, the proposing node, and the plurality of consensus nodes may determine the distance between the target random information and the hash value of the node information of each of the other nodes, and determine the other node with the smallest distance as the new block-producing node. The distance between the target random information and the hash value of the node information of each of the other nodes may be, for example, the Hamming distance or the Levenshtein distance.
[0071] Figure 3 is a flowchart of step S200 provided by an exemplary embodiment of the present disclosure. In some optional implementations, in the embodiment of the present disclosure, step S200 may include the following steps:
[0072] Step S201, the node obtains the target historical block from the blockchain based on a preset block selection rule.
[0073] Among them, the preset block selection rule may include, for example: taking the latest block on the blockchain as the target historical block.
[0074] In one embodiment, the block-producing node, the proposing node, and each of the plurality of consensus nodes respectively obtain the latest block on the blockchain (target historical block).
[0075] Step S202, the node determines the target random information based on the target historical block.
[0076] Among them, the hash value of the target historical block can be used as the target random information.
[0077] Exemplarily, a block-producing node, a proposing node, and each of multiple consensus nodes obtains a target historical block as a seed, and determines the distance between a hash value of the seed (target random information) and a hash value of address information (node information) of each of the multiple consensus nodes, and determines the consensus node with the smallest distance as a new block-producing node.
[0078] In the embodiment of the present disclosure, the target historical block is determined based on a preset block selection rule, and the target random information is determined by the target historical block, thereby ensuring the consistency of the target random information obtained by each node in the blockchain network, and further ensuring the consistency of the new block-producing node selected by each node in the blockchain network.
[0079] Figure 4 FIG. 1 is a flowchart of a transaction processing method based on blockchain provided by another exemplary embodiment of the present disclosure. In some optional implementations, such as Figure 4 As shown, in the embodiment of the present disclosure, the following steps may also be included before step S100:
[0080] Step S300, in response to the proposing node and / or any consensus node among the multiple consensus nodes receiving the transaction information, the proposing node and / or any consensus node sends the transaction information to the block producing node.
[0081] Among them, when the proposing node receives the transaction information sent by the user, the proposing node sends the transaction information to the block-producing node; when any consensus node receives the transaction information sent by the user, the any consensus node sends the transaction information to the block-producing node; when the block-producing node receives the transaction information sent by the user, it directly stores the transaction information in the transaction pool corresponding to the block-producing node.
[0082] Step S310: The block-producing node updates the transaction information to the transaction pool corresponding to the block-producing node.
[0083] In one embodiment, the block producing node receives the transaction information sent by the proposing node and / or any consensus node, and stores the transaction information in the transaction pool corresponding to the block producing node to update the transaction information to the transaction pool corresponding to the block producing node.
[0084] In the disclosed embodiment, when the proposing node and the consensus node receive the transaction information, they directly send the transaction information to the block-producing node, and the transaction pool corresponding to the block-producing node stores the transaction information, thereby reducing storage overhead and improving the performance of the blockchain network.
[0085] In some optional implementations, in the embodiments of the present disclosure, the blockchain-based transaction processing method may also include: in response to the proposing node not receiving a new block within a first preset time period, for each node in the blockchain network, the node determines a new block-producing node from other nodes in the blockchain network except the block-producing node; or, in response to multiple consensus nodes not receiving a block to be chained within a second preset time period, for each node in the blockchain network, the node determines a new block-producing node from other nodes in the blockchain network except the block-producing node.
[0086] Among them, the first preset time length and the second preset time length can be set according to the actual needs of the blockchain network. For example, the first preset time length and the second preset time length can be 1s, etc.
[0087] In one embodiment, when a proposing node fails to receive a new block within a first preset time period after the last consensus processing of a block, or when multiple consensus nodes fail to receive a block to be uploaded to the chain within a second preset time period after the last consensus processing of a block, the block-producing node may fail, crash, or act maliciously. Each node in the blockchain network generates a message that a new block has not been received, and signs the message that a new block has not been received. At the same time, the signed message that a new block has not been received is broadcast to nodes other than the node in the blockchain network. When the node receives the signed message that a new block has not been received sent by 2 / 3 of the nodes in the blockchain network, the node determines a new block-producing node from other nodes. For example, the new block-producing node can be determined from multiple consensus nodes.
[0088] The method for determining a new block-generating node when the proposing node and multiple consensus nodes in the blockchain network do not receive a new block within a preset time period can refer to the method for determining a new block-generating node when the consensus height is greater than or equal to the preset number of blocks, which will not be repeated here. In the embodiment of the present disclosure, when a block-generating node cannot normally generate a block (generate a new block), the nodes in the blockchain network promptly determine a new block-generating node from other nodes, thereby ensuring the normal operation of the blockchain network.
[0089] In some optional implementations, in the embodiments of the present disclosure, after determining the new block producing node, the process may further include: the new block producing node obtains transaction information that is not stored in the blockchain from the block producing node, and stores the transaction information in the transaction pool corresponding to the new block producing node.
[0090] Among them, the transaction information that is not stored in the blockchain may be transaction information that has not formed a block, that is, transaction information that has not been put on the chain.
[0091] In one embodiment, the new block-producing node may request the block-producing node for transaction information that is not stored in the blockchain, and then the block-producing node sends the transaction information in its corresponding transaction pool that is not stored in the blockchain to the new block-producing node. The block-producing node may delete all transaction information in its corresponding transaction pool, and the new fast node stores the transaction information that is not stored in the blockchain into the transaction pool corresponding to the new block-producing node.
[0092] In the disclosed embodiment, the new block-producing node obtains the transaction information that is not stored in the blockchain from the block-producing node, and stores it in the transaction pool corresponding to the new block-producing node, thereby avoiding the omission of transaction information and ensuring that each transaction information can be stored in the blockchain.
[0093] In some optional implementations, in the disclosed embodiments, the blockchain network further includes: at least one candidate node, the candidate node being respectively connected to the proposing node, the plurality of consensus nodes, and the block producing node. The candidate node can be used as a rotating block producing node. Exemplarily, the blockchain network can include a plurality of candidate nodes.
[0094] Accordingly, step S130 in this embodiment may also include: the proposing node sends the block to be chained to multiple consensus nodes, and the multiple consensus nodes and the proposing node perform consensus processing on the block to be chained.
[0095] Among them, the proposing node can initiate consensus on the blocks to be on the chain to multiple consensus nodes, and multiple consensus nodes and proposing nodes perform consensus processing on the blocks to be on the chain based on a preset consensus algorithm.
[0096] In one embodiment, the block generating node is only used to generate blocks and does not participate in consensus and store blockchains. Accordingly, step S140 may include: multiple consensus nodes and proposal nodes add the blocks to be chained to their respective blockchains.
[0097] In some optional embodiments, in the embodiments of the present disclosure, the blockchain-based transaction processing method in the embodiments of the present application also includes: in response to the consensus height of multiple consensus nodes and proposal nodes being greater than or equal to a preset number of blocks, the multiple consensus nodes and proposal nodes respectively determine a new block-producing node from at least one candidate node.
[0098] Among them, the method of determining a new block-generating node from candidate nodes can refer to the method of determining a new block-generating node from other nodes, which will not be repeated here.
[0099] In some optional embodiments, in the embodiments of the present disclosure, the blockchain-based transaction processing method in the embodiments of the present application also includes: in response to the proposing node not receiving a new block within a first preset time length, for each node in the blockchain network, the node determines a new block-generating node from at least one candidate node; or, in response to multiple consensus nodes not receiving a block to be chained within a second preset time length, for each node in the blockchain network, the node determines a new block-generating node from at least one candidate node.
[0100] Among them, the method of determining a new block-generating node from candidate nodes can refer to the method of determining a new block-generating node from other nodes, which will not be repeated here.
[0101] Figure 5 It is a schematic diagram of a blockchain network provided by an application example of the present disclosure. Figure 6 It is a schematic diagram of a blockchain-based transaction processing method provided by an application example of the present disclosure.
[0102] like Figure 5 As shown, in the blockchain network, the blockchain network includes: a block node, a proposal node and multiple consensus nodes, each of which includes a transaction pool, and the block node, the proposal node and the multiple consensus nodes can be connected to the user's client through a wired network or a wireless network. Among them, the transaction pool in the block node (the transaction pool corresponding to the block node) is in a working state, and the transaction pools in the proposal node and the multiple consensus nodes are in a non-working state. The block node is respectively connected to the proposal node and the multiple consensus nodes through a wireless network or a wired network, the proposal node is connected to the multiple consensus nodes through a wireless network or a wired network, and the multiple consensus nodes are connected to each other through a wireless network or a wired network.
[0103] like Figure 6 As shown, in this application example, the transaction processing method based on blockchain may include:
[0104] The user can send transaction information to the proposing node or any consensus node through his client. When the proposing node or any consensus node receives the transaction information sent by the client, the proposing node or any consensus node sends the transaction information to the block-producing node. The block-producing node receives the transaction information and stores it in the transaction pool corresponding to the block-producing node.
[0105] When a block-producing node receives a block acquisition request sent by a proposing node, the block-producing node deletes the transaction information corresponding to the previous block in the transaction pool corresponding to the block-producing node based on the block information of the previous block in the block acquisition request, so as to update the transaction pool corresponding to the block-producing node. The block-producing node generates a new block based on the transaction information in the transaction pool corresponding to the block-producing node, and sends the new block to the proposing node. The proposing node executes each transaction information in the new block, and writes the transaction result of each transaction information into the new block to obtain a block to be chained. The proposing node sends the block to be chained to multiple consensus nodes and block-producing nodes, and multiple consensus nodes, proposing nodes and block-producing nodes perform consensus processing on the block to be chained. When the block to be chained passes the consensus, the block to be chained is added to the blockchain.
[0106] When the proposing node does not receive a new block within a first preset time period, for each node in the blockchain network, the node determines a new block-producing node from other nodes in the blockchain network except the block-producing node; or, when multiple consensus nodes do not receive a block to be chained within a second preset time period, for each node in the blockchain network, the node determines a new block-producing node from other nodes in the blockchain network except the block-producing node.
[0107] Figure 7 is a block diagram of a transaction processing device based on blockchain provided by an exemplary embodiment of the present disclosure. This embodiment can be applied to a blockchain network, which includes: a block node, a proposal node, and multiple consensus nodes, such as Figure 7 As shown, the blockchain-based transaction processing device includes:
[0108] The first transaction pool updating module 400 is configured to, in response to the block generation node receiving the block acquisition request sent by the proposing node, delete the transaction information corresponding to the previous block in the transaction pool corresponding to the block generation node based on the block information of the previous block in the block generation request, so as to update the transaction pool corresponding to the block generation node;
[0109] The block generation module 410 is used for the block generation node to generate a new block based on the transaction information in the transaction pool corresponding to the block generation node, and send the new block to the proposing node;
[0110] The transaction execution module 420 is used for the proposing node to execute each transaction information in the new block, and write the transaction result of each transaction information into the new block to obtain a block to be chained;
[0111] A consensus module 430, used for the proposing node to initiate a consensus process on the block to be chained in the blockchain network;
[0112] The chain module 440 is used to add the block to the blockchain in response to the block to be chained passing the consensus.
[0113] In one embodiment of the present disclosure, the consensus module 430 in the embodiment of the present disclosure is specifically used for the proposing node to send the block to be chained to the multiple consensus nodes and the block-producing nodes, and the multiple consensus nodes, the proposing node and the block-producing nodes perform consensus processing on the block to be chained.
[0114] In one embodiment of the present disclosure, the blockchain-based transaction processing device in the embodiment of the present disclosure further includes:
[0115] The first node replacement module is used for each node in the blockchain network, in response to the consensus height of the node being greater than or equal to a preset number of blocks, the node determining a new block-producing node from other nodes in the blockchain network except the block-producing node.
[0116] In one embodiment of the present disclosure, the node in the embodiment of the present disclosure determines a new block-producing node from other nodes in the blockchain network except the block-producing node, and is further used to:
[0117] The node determines the new block-producing node from among the other nodes based on a preset block-producing node order.
[0118] In one embodiment of the present disclosure, the node in the embodiment of the present disclosure determines a new block-producing node from other nodes in the blockchain network except the block-producing node, and is further used to:
[0119] The node obtains target random information;
[0120] The node determines the new block generating node based on the distance between the target random information and the node information of other nodes.
[0121] In one embodiment of the present disclosure, the node in the embodiment of the present disclosure obtains target random information, which is further used to:
[0122] The node obtains a target historical block from the blockchain based on a preset block selection rule;
[0123] The node determines the target random information based on the target historical block.
[0124] In one embodiment of the present disclosure, the blockchain-based transaction processing device in the embodiment of the present disclosure further includes:
[0125] A transaction information sending module, configured to, in response to the proposal node and / or any consensus node among the plurality of consensus nodes receiving the transaction information, send the transaction information to the block producing node by the proposal node and / or any consensus node;
[0126] The second transaction pool updating module is used for the block producing node to update the transaction information into the transaction pool.
[0127] In one embodiment of the present disclosure, the blockchain-based transaction processing device in the embodiment of the present disclosure further includes:
[0128] The second node replacement module is used for, in response to the proposing node not receiving the new block within the first preset time length, for each node in the blockchain network, the node determines a new block-producing node from other nodes in the blockchain network except the block-producing node; or, in response to the multiple consensus nodes not receiving the to-be-chained block within the second preset time length, for each node in the blockchain network, the node determines a new block-producing node from other nodes in the blockchain network except the block-producing node.
[0129] In one embodiment of the present disclosure, the blockchain-based transaction processing device in the embodiment of the present disclosure further includes:
[0130] A transaction information acquisition module is used for the new block-producing node to obtain transaction information that is not stored in the blockchain from the block-producing node, and store it in the transaction pool corresponding to the new block-producing node.
[0131] In one embodiment of the present disclosure, the blockchain network in the embodiment of the present disclosure further includes: at least one candidate node; the consensus module 430 in the embodiment of the present disclosure is also used for the proposing node to send the block to be chained to the multiple consensus nodes, and the multiple consensus nodes and the proposing node perform consensus processing on the block to be chained.
[0132] In one embodiment of the present disclosure, the blockchain-based transaction processing device in the embodiment of the present disclosure further includes:
[0133] The third node replacement module is used to respond to the consensus height of the multiple consensus nodes and the proposed node being greater than or equal to a preset number of blocks, and the multiple consensus nodes and the proposed node respectively determine a new block-producing node from the at least one candidate node.
[0134] In one embodiment of the present disclosure, the blockchain-based transaction processing device in the embodiment of the present disclosure further includes:
[0135] The fourth node replacement module is used to, in response to the proposing node not receiving the new block within the first preset time length, for each node in the blockchain network, the node determines a new block-generating node from the at least one candidate node; or, in response to the multiple consensus nodes not receiving the block to be chained within the second preset time length, for each node in the blockchain network, the node determines a new block-generating node from the at least one candidate node.
[0136] The blockchain-based transaction processing device of the embodiment of the present disclosure corresponds to the embodiment of the blockchain-based transaction processing method of the present disclosure, and the relevant contents can be referenced to each other and will not be repeated here.
[0137] The beneficial technical effects corresponding to the exemplary embodiment of the blockchain-based transaction processing device of the disclosed embodiment can be found in the corresponding beneficial technical effects of the above-mentioned corresponding exemplary method part, which will not be repeated here.
[0138] In addition, an embodiment of the present disclosure further provides an electronic device, including:
[0139] Memory for storing computer programs;
[0140] The processor is used to execute the computer program stored in the memory, and when the computer program is executed, the blockchain-based transaction processing method described in any of the above embodiments of the present disclosure is implemented.
[0141] Figure 8 This is a schematic diagram of the structure of an application embodiment of the electronic device disclosed in the present invention. Figure 8 The electronic device according to the embodiment of the present disclosure is described. The electronic device may be any one or both of the first device and the second device, or a stand-alone device independent of them, and the stand-alone device may communicate with the first device and the second device to receive the collected input signals from them.
[0142] like Figure 8 As shown, the electronic device includes one or more processors and memory.
[0143] The processor may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0144] The memory may include one or more computer program products, and the computer program product may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor may execute the program instructions to implement the transaction processing method based on blockchain and / or other desired functions of the various embodiments of the present disclosure described above.
[0145] In one example, the electronic device may further include: an input device and an output device, and these components are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0146] In addition, the input device may also include, for example, a keyboard, a mouse, and the like.
[0147] The output device can output various information to the outside, including the determined distance information, direction information, etc. The output device can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto, and the like.
[0148] Of course, to simplify, Figure 8 Only some of the components related to the present disclosure in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device may further include any other appropriate components.
[0149] In addition to the above-mentioned methods and devices, an embodiment of the present disclosure may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps in the blockchain-based transaction processing method according to various embodiments of the present disclosure described in the above part of this specification.
[0150] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the disclosed embodiments, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0151] In addition, an embodiment of the present disclosure may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, cause the processor to execute the steps of the blockchain-based transaction processing method according to various embodiments of the present disclosure described in the above part of this specification.
[0152] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0153] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above-mentioned method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above-mentioned method embodiment; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk, etc., various media that can store program codes.
[0154] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.
[0155] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0156] The block diagrams of the devices, apparatuses, equipment, and systems involved in this disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including," "comprising," "having," and the like are open words, referring to "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or," and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.
[0157] The method and apparatus of the present disclosure may be implemented in many ways. For example, the method and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.
[0158] It should also be noted that in the apparatus, device and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.
[0159] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use the present disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0160] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A transaction processing method based on blockchain, characterized in that: Applied to a blockchain network, the blockchain network includes: a block-producing node, a proposal node, and a plurality of consensus nodes, the method includes: In response to the block producing node receiving the block acquisition request sent by the proposing node, the block producing node deletes the transaction information corresponding to the previous block in the transaction pool corresponding to the block producing node based on the block information of the previous block in the block acquisition request, so as to update the transaction pool corresponding to the block producing node; The block producing node generates a new block based on the transaction information in the transaction pool corresponding to the block producing node, and sends the new block to the proposing node; The proposing node executes each transaction information in the new block, and writes the transaction result of each transaction information into the new block to obtain a block to be chained; The proposing node initiates a consensus process on the block to be chained in the blockchain network; In response to the block to be chained passing the consensus, the block to be chained is added to the blockchain.
2. The method according to claim 1, characterized in that: The proposing node initiates a consensus process on the block to be chained in the blockchain network, including: The proposing node sends the block to be chained to the multiple consensus nodes and the block-producing node, and the multiple consensus nodes, the proposing node and the block-producing node perform consensus processing on the block to be chained.
3. The method according to claim 1, characterized in that Also includes: For each node in the blockchain network, in response to the consensus height of the node being greater than or equal to a preset number of blocks, the node determines a new block-producing node from other nodes in the blockchain network except the block-producing node.
4. The method according to claim 3, characterized in that The node determines a new block-producing node from other nodes in the blockchain network except the block-producing node, including: The node determines the new block-producing node from among the other nodes based on a preset block-producing node order.
5. The method according to claim 3, characterized in that: The node determines a new block-producing node from other nodes in the blockchain network except the block-producing node, including: The node obtains target random information; The node determines the new block generating node based on the distance between the target random information and the node information of other nodes.
6. The method according to claim 5, characterized in that The node obtains target random information, including: The node obtains a target historical block from the blockchain based on a preset block selection rule; The node determines the target random information based on the target historical block.
7. The method according to any one of claims 1 to 6, characterized in that: Before the block generation node receives the block acquisition request sent by the proposal node, the method further includes: In response to the proposing node and / or any one of the plurality of consensus nodes receiving the transaction information, the proposing node and / or any one of the consensus nodes sends the transaction information to the block producing node; The block producing node updates the transaction information to the transaction pool.
8. The method according to claim 1, characterized in that: Also includes: In response to the proposing node not receiving the new block within a first preset time period, for each node in the blockchain network, the node determines a new block-producing node from other nodes in the blockchain network except the block-producing node; or, In response to the multiple consensus nodes not receiving the to-be-chained block within a second preset time period, for each node in the blockchain network, the node determines a new block-producing node from other nodes in the blockchain network except the block-producing node.
9. The method according to claim 3 or 8, characterized in that: Also includes: The new block producing node obtains the transaction information that is not stored in the blockchain from the block producing node, and stores it in the transaction pool corresponding to the new block producing node.
10. The method according to claim 1, characterized in that The blockchain network also includes: at least one candidate node; The proposing node initiates a consensus process on the block to be chained in the blockchain network, including: The proposing node sends the block to be chained to the multiple consensus nodes, and the multiple consensus nodes and the proposing node perform consensus processing on the block to be chained.
11. The method according to claim 10, characterized in that The method further comprises: In response to the consensus height of the multiple consensus nodes and the proposing node being greater than or equal to a preset number of blocks, the multiple consensus nodes and the proposing node respectively determine a new block-producing node from the at least one candidate node.
12. The method according to claim 11, characterized in that The method further comprises: In response to the proposing node not receiving the new block within a first preset time period, for each node in the blockchain network, the node determines a new block-producing node from the at least one candidate node; or, In response to the multiple consensus nodes not receiving the to-be-chained block within a second preset time period, for each node in the blockchain network, the node determines a new block-generating node from the at least one candidate node.
13. A transaction processing device based on blockchain, characterized in that: Applied to a blockchain network, the blockchain network includes: a block-producing node, a proposal node and a plurality of consensus nodes, and the device includes: A first transaction pool updating module, configured to, in response to the block producing node receiving the block acquisition request sent by the proposing node, delete the transaction information corresponding to the previous block in the transaction pool corresponding to the block producing node based on the block information of the previous block in the block acquisition request, so as to update the transaction pool corresponding to the block producing node; A block generation module, used for the block generation node to generate a new block based on the transaction information in the transaction pool corresponding to the block generation node, and send the new block to the proposing node; A transaction execution module, used for the proposing node to execute each transaction information in the new block, and write the transaction result of each transaction information into the new block to obtain a block to be put on the chain; A consensus module, used for the proposing node to initiate a consensus process on the block to be chained in the blockchain network; The chain module is used to add the block to the blockchain in response to the block to be chained passing the consensus.
14. An electronic device, characterized in that: include: Memory for storing computer programs; A processor is used to execute the computer program stored in the memory, and when the computer program is executed, the blockchain-based transaction processing method described in any one of claims 1 to 12 is implemented.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the blockchain-based transaction processing method described in any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Block-link data shrinking method and device and storage medium
CN109324757A
Parallel transaction processing method and device for transaction input set
CN111047306A
Consensus method and consensus system
CN111414373A
Data storage method and device based on blockchain network, related equipment and medium
CN111885050A
Block chain-based data processing method, device and equipment, and readable storage medium
CN113409047A