Transaction processing method, apparatus, device, readable storage medium and program product
By obtaining the state data of the transaction participants in the processing node, the problem of low efficiency in blockchain transaction processing is solved, and a more efficient processing speed is achieved.
Patent Information
- Application Number
- CN202411738222.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2026-01-20
- Estimated Expiration
- 2044-11-29
AI Technical Summary
Blockchain technology suffers from low transaction processing efficiency because state data is stored on disk, which needs to be improved.
In the absence of target state data stored in the processing node, the target state data is obtained from the state node corresponding to the transaction participant, and then processed according to the first state data and the second state data.
It improves the efficiency of transaction processing, reduces disk access, and increases processing speed.
Smart Images

Figure CN119652970B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of Ethereum, and in particular to a transaction processing method and device, equipment, readable storage medium and program product. BACKGROUND
[0002] With the growth of online transaction volume, in order to facilitate the processing of transactions, and the management of transaction processing records, based on the blockchain to manage transaction processing records has become the mainstream way. However, the application field of the blockchain technology is limited, and the development difficulty is great, based on this, the Ethereum network appears. In the Ethereum network, there are world state and account state.
[0003] Usually, the state data of different accounts is stored in the disk, and in the process of transaction processing, the state data needs to be searched and updated, so in the process of transaction processing, the access to the disk is involved, which is easy to cause low transaction processing efficiency and needs to be solved. SUMMARY
[0004] Therefore, it is necessary to provide a transaction processing method, device, equipment, readable storage medium and program product capable of improving transaction processing efficiency.
[0005] In a first aspect, the present application provides a transaction processing method, comprising:
[0006] Obtaining a transaction request initiated by a transaction initiator; wherein the transaction request comprises identification information of a transaction participant corresponding to a to-be-processed transaction; the transaction participant comprises the transaction initiator and a transaction receiver;
[0007] According to the identification information of the transaction initiator, determining a processing node corresponding to the transaction request, and sending the transaction request to the processing node;
[0008] In the case where the target state data is not stored in the processing node, controlling the processing node to obtain the target state data from a state node corresponding to the transaction participant; wherein the target state data comprises first state data of the transaction initiator, and / or second state data of the transaction receiver;
[0009] Controlling the processing node to process the to-be-processed transaction according to the first state data and the second state data.
[0010] In one of the embodiments, the controlling the processing node to obtain the target state data from the state node corresponding to the transaction participant comprises:
[0011] According to the storage of the state data of each transaction participant in the processing node, the control processing node selects the state node corresponding to the target transaction participant from at least two candidate nodes corresponding to the processing node according to the identification information of the target transaction participant, and obtains the target state data from the state node.
[0012] Wherein, the state data of the target transaction participant is not stored in the processing node.
[0013] In one embodiment, according to the identification information of the target transaction participant, the state node corresponding to the target transaction participant is selected from at least two candidate nodes corresponding to the processing node, comprising:
[0014] According to the identification information of the target transaction participant, and the mapping relationship corresponding to the processing node, the state node corresponding to the target transaction participant is selected from at least two candidate state nodes corresponding to the processing node.
[0015] In one embodiment, the target state data is obtained from the state node, comprising:
[0016] Sending a data acquisition request to the state node;
[0017] In the case that the state node allows to respond to the data acquisition request, the target state data is obtained from the state node.
[0018] In one embodiment, the transaction request includes transaction content; accordingly, the control processing node processes the to-be-processed transaction according to the first state data and the second state data, comprising:
[0019] The control processing node adjusts the first state data and the second state data based on the transaction content to process the to-be-processed transaction in the case that the first state data and the second state data satisfy the transaction request;
[0020] In the case that the first state data and / or the second state data does not satisfy the transaction request, the transaction request is rejected.
[0021] In one embodiment, the method further comprises:
[0022] In the case that the first state data and the second state data of the transaction initiator and the transaction participant stored in the processing node satisfy the transaction request, the control processing node adjusts the first state data and the second state data based on the transaction content to process the to-be-processed transaction;
[0023] Accordingly, after adjusting the first state data and the second state data, the method further comprises:
[0024] The state adjustment instruction is sent to a state node corresponding to the transaction participant, so that the corresponding state node adjusts the recorded state data.
[0025] In a second aspect, the present application further provides a transaction processing apparatus, comprising:
[0026] The request obtaining module is configured to obtain a transaction request initiated by a transaction initiator, wherein the transaction request comprises identification information of a transaction participant corresponding to a to-be-processed transaction, and the transaction participant comprises the transaction initiator and a transaction receiver.
[0027] The processing node determining module is configured to determine a processing node corresponding to the transaction request according to the identification information of the transaction initiator, and send the transaction request to the processing node.
[0028] The data obtaining module is configured to, in a case where the target state data is not stored in the processing node, control the processing node to obtain the target state data from a state node corresponding to the transaction participant.
[0029] The first transaction processing module is configured to control the processing node to process the to-be-processed transaction according to the first state data and the second state data.
[0030] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0031] The transaction request initiated by the transaction initiator is obtained, wherein the transaction request comprises identification information of a transaction participant corresponding to a to-be-processed transaction, and the transaction participant comprises the transaction initiator and a transaction receiver.
[0032] The processing node corresponding to the transaction request is determined according to the identification information of the transaction initiator, and the transaction request is sent to the processing node.
[0033] In a case where the target state data is not stored in the processing node, the processing node is controlled to obtain the target state data from a state node corresponding to the transaction participant, wherein the target state data comprises first state data of the transaction initiator and / or second state data of the transaction receiver.
[0034] The processing node is controlled to process the to-be-processed transaction according to the first state data and the second state data.
[0035] In a fourth aspect, the present application further provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the following steps:
[0036] acquire a transaction request initiated by a transaction initiator; wherein the transaction request comprises identification information of a transaction participant corresponding to a to-be-processed transaction; the transaction participant comprises the transaction initiator and a transaction receiver;
[0037] determine a processing node corresponding to the transaction request according to the identification information of the transaction initiator, and send the transaction request to the processing node;
[0038] in a case where the target state data is not stored in the processing node, control the processing node to acquire the target state data from a state node corresponding to the transaction participant; wherein the target state data comprises first state data of the transaction initiator, and / or second state data of the transaction receiver;
[0039] control the processing node to process the to-be-processed transaction according to the first state data and the second state data.
[0040] In a fifth aspect, the present application further provides a computer program product comprising a computer program which, when executed by a processor, implements the following steps:
[0041] acquire a transaction request initiated by a transaction initiator; wherein the transaction request comprises identification information of a transaction participant corresponding to a to-be-processed transaction; the transaction participant comprises the transaction initiator and a transaction receiver;
[0042] determine a processing node corresponding to the transaction request according to the identification information of the transaction initiator, and send the transaction request to the processing node;
[0043] in a case where the target state data is not stored in the processing node, control the processing node to acquire the target state data from a state node corresponding to the transaction participant; wherein the target state data comprises first state data of the transaction initiator, and / or second state data of the transaction receiver;
[0044] control the processing node to process the to-be-processed transaction according to the first state data and the second state data.
[0045] The transaction processing method, device, equipment, readable storage medium and program product can determine a processing node responsible for processing the to-be-processed transaction according to the transaction initiator of the to-be-processed transaction when the to-be-processed transaction exists, and send a transaction request to the processing node to request the processing node to process the transaction request. Further, the processing node is controlled to process the to-be-processed transaction, in the case that the target state data is not stored in the processing node, the target state data is obtained from the state node corresponding to the transaction participant, and then the processing node processes the to-be-processed transaction according to the first state data and the second state data. In the above process, in order to improve the transaction processing speed of the processing node, only a part of the state data is stored in the transaction processing node, in the case that the target state data is not stored in the transaction processing node, the target state data is obtained from the corresponding state node, and then the processing of the to-be-processed transaction is completed, and the whole process can improve the transaction processing efficiency. BRIEF DESCRIPTION OF DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the drawings needed to be used in the description of the embodiments of the present application or the related art will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other related drawings can be obtained by those skilled in the art without creative labor.
[0047] Figure 1 An application environment diagram of a transaction processing method in an embodiment;
[0048] Figure 2A A flowchart of a transaction processing method in an embodiment;
[0049] Figure 2B A distributed Merkle tree D-MPT architecture diagram in an embodiment;
[0050] Figure 3 A flowchart of a target state data obtaining step in an embodiment;
[0051] Figure 4 A flowchart of a to-be-processed transaction processing step in an embodiment;
[0052] Figure 5 A flowchart of a transaction processing method in another embodiment;
[0053] Figure 6A A flowchart of a transaction processing method in another embodiment;
[0054] Figure 6B A state virtual node diagram in an embodiment;
[0055] Figure 7 A structural block diagram of a transaction processing device in an embodiment;
[0056] Figure 8 An internal structural diagram of a computer device in an embodiment. DETAILED DESCRIPTION
[0057] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application is further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not intended to limit the present application.
[0058] The transaction processing method provided by the embodiments of the present application can be applied to an application environment as shown in Figure 1 . The terminal 102 communicates with the blockchain 104 through a network. The data storage system can store data required to be processed by the blockchain 104. The blockchain 104 obtains a transaction request initiated by a transaction initiator; wherein the transaction request includes identification information of a transaction participant corresponding to a to-be-processed transaction; the transaction participant includes the transaction initiator and a transaction receiver; the blockchain 104 determines a processing node corresponding to the transaction request according to the identification information of the transaction initiator, and sends the transaction request to the processing node; in the case that the processing node does not store target state data, the blockchain 104 controls the processing node to obtain the target state data from a state node corresponding to the transaction participant; wherein the target state data includes first state data of the transaction initiator, and / or second state data of the transaction receiver; the blockchain 104 controls the processing node to process the to-be-processed transaction according to the first state data and the second state data. The terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things device can be a smart speaker, a smart television, a smart air conditioner, a smart vehicle-mounted device, a projection device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc.
[0059] In an exemplary embodiment, as shown in Figure 2A , a transaction processing method is provided. Taking the blockchain 104 in Figure 1 as an example, the method can include the following steps:
[0060] S210, obtaining a transaction request initiated by a transaction initiator.
[0061] The transaction request includes identification information of a transaction participant corresponding to a to-be-processed transaction, and the transaction request is used to request the distributed data storage system to process the corresponding transaction, and the distributed data storage system processes the transaction based on a block chain network.
[0062] The transaction participant includes a transaction initiator and a transaction receiver. For example, account A transfers 100 yuan to account B, and the transfer is initiated by account A. Accordingly, account A is the transaction initiator, and account B is the transaction receiver. The identification information of the transaction participant is used to uniquely mark the identity information of the transaction participant. For example, the identification information can be account information or a preset unique identifier.
[0063] In this embodiment, the transaction initiator can input the transaction request through the transaction platform. At this time, the system can receive the corresponding transaction request.
[0064] S220, according to the identification information of the transaction initiator, determining the processing node corresponding to the transaction request, and sending the transaction request to the processing node.
[0065] The processing node can be a node for processing the transaction request. The distributed storage system includes at least two processing nodes, wherein different processing nodes are used to process transaction requests initiated by different transaction initiators. For example, processing node 1 is used to process transaction requests initiated by transaction initiators 1-10; processing node 2 is used to process transaction requests initiated by transaction initiators 2-20.
[0066] Specifically, in this embodiment, the correspondence between the predetermined reference transaction initiator and the reference processing node is determined, and the reference processing node corresponding to the identification information of the transaction initiator in the correspondence is used as the processing node corresponding to the transaction request. Further, the transaction request is sent to the processing node for processing the transaction request.
[0067] In this embodiment, the distributed data storage system can be based on a block chain for business processing support. For example, it can be an Ethereum block chain.
[0068] In this embodiment, the distributed storage system can be implemented in a distributed Merkle tree D-MPT architecture. For example, the world state tree is horizontally and horizontally divided, and the original structure is divided into a top part and a bottom part of the state tree. The top part is the node close to the root of the original state tree. As shown in Figure 2B The entire architecture includes a top part and a bottom part, wherein the top part has nodes A, B, and C. The bottom part is a number of state subtrees, each of which has only a small amount of state data, such as Figure 2BThe middle state subtree subtree-1 has nodes D, G, H, and only two account states G, H.
[0069] It should be noted that in the D-MPT architecture, there are two kinds of nodes: one is a miner node: the miner node participates in the transaction execution of the system, needs to obtain account data, and update data. In the D-MPT architecture, there is only one miner node, which saves the top part of the state tree and some active state data. The other is a state node: the state node saves a part of the state data and the corresponding witness data in the memory in the form of a state subtree. If the size of the state data grows to a certain extent, the capacity can be expanded by increasing the state nodes in the system. In the entire distributed data storage system, there are multiple distributed Merkle trees as shown in the figure, and different miner nodes are used to process different account transactions. Figure 2B
[0070] S230, in the case where the target state data is not stored in the processing node, the processing node is controlled to obtain the target state data from the state node corresponding to the transaction participant.
[0071] The target state data includes first state data of the transaction initiator and / or second state data of the transaction recipient. The first state data represents the state data corresponding to the transaction transaction completed by the transaction initiator in the historical period; and the second state data represents the state data corresponding to the transaction transaction completed by the transaction recipient in the historical period.
[0072] In this embodiment, the processing node stores active state data. The active state data is state data accessed by the system in the recent period of time, or state data required to be accessed in the recent period of time of the system.
[0073] Optionally, in the case where the first state data and the second state data are stored in the processing node, the processing node can be directly controlled to process the corresponding transaction request. In the case where the first state data is not stored in the processing node, or the second state data is not stored in the processing node, the processing node is controlled to obtain the state data not stored from the state node corresponding to the transaction participant. For example, if the first state data is not stored in the processing node, the processing node is controlled to obtain the first state data from the state node corresponding to the transaction initiator; if the second state data is not stored in the processing node, the processing node is controlled to obtain the second state data from the state node corresponding to the transaction recipient.
[0074] In the embodiment, there is a corresponding relationship between each transaction participant and the corresponding state node, that is, after determining the owner of the target state data not stored in the processing node, the processing node can obtain the target state data from the corresponding state node according to the corresponding relationship.
[0075] In S240, the processing node processes the to-be-processed transaction according to the first state data and the second state data.
[0076] Specifically, in the embodiment, the first state data and the second state data are adjusted based on the transaction content of the to-be-processed transaction to process the to-be-processed transaction.
[0077] For example, the transaction content of the to-be-processed transaction is that account A transfers 100 yuan to account B, the processing node can be controlled to lower the balance in the first state data by 100 yuan and increase the balance in the second state data by 100 yuan.
[0078] Further, in order to facilitate subsequent queries, the transaction processing time corresponding to the to-be-processed transaction can also be added to the state data corresponding to the transaction participant in the embodiment.
[0079] In the above transaction processing method, when there is a to-be-processed transaction, the processing node responsible for processing the to-be-processed transaction is determined according to the transaction initiator of the to-be-processed transaction, and the transaction request is sent to the processing node to request the processing node to process the transaction request. Further, the processing node processes the to-be-processed transaction, and when the target state data is not stored in the processing node, the processing node obtains the target state data from the state node corresponding to the transaction participant, and then controls the processing node to process the to-be-processed transaction according to the first state data and the second state data. In the above process, in order to improve the transaction processing speed of the processing node, only a part of the state data is stored in the transaction processing node, and when the target state data is not stored in the transaction processing node, the target state data is obtained from the corresponding state node, and then the processing of the to-be-processed transaction is completed, which can improve the transaction processing efficiency.
[0080] Based on the technical solutions of the above embodiments, the present application further provides an optional embodiment. In the optional embodiment, the process of controlling the processing node to obtain the target state data from the state node corresponding to the transaction participant is refined.
[0081] Referring to the target state data obtaining step shown in Figure 3
[0082] S310, according to storage of the state data corresponding to each transaction participant in the processing node, controlling the processing node to select the state node corresponding to the target transaction participant from at least two candidate nodes corresponding to the processing node according to the identification information of the target transaction participant, and acquire the target state data from the state node.
[0083] The processing node corresponds to at least two candidate nodes, and the candidate node is a state node for storing state data of a corresponding user.
[0084] The state data of the target transaction participant is not stored in the processing node. It can be understood that in the embodiment, if the first state data corresponding to the transaction initiator is not stored in the processing node, the transaction initiator is taken as the target transaction participant; if the second state data corresponding to the transaction receiver is not stored in the processing node, the transaction receiver is taken as the target transaction participant.
[0085] Exemplarily, in the embodiment, the correspondence between the reference participant and the reference state node can be determined in advance, and after the target transaction participant is determined, the reference state node corresponding to the target transaction participant in the correspondence is taken as the state node corresponding to the target transaction participant.
[0086] Optionally, in the embodiment, the state node corresponding to the target transaction participant can be selected from at least two candidate state nodes corresponding to the processing node according to the identification information of the target transaction participant and the mapping relationship corresponding to the processing node.
[0087] The mapping relationship is used to represent the correspondence between the identification information and the state node. Correspondingly, the reference state node corresponding to the identification information of the target transaction participant in the mapping relationship is taken as the state node corresponding to the target transaction participant.
[0088] In the embodiment, the construction method and construction process of the mapping relationship are not limited. Exemplarily, the mapping relationship can be constructed based on a hash ring.
[0089] S320, sending a data acquisition request to the state node.
[0090] Specifically, in the embodiment, the processing node sends a data acquisition request to the state node to request the target state data.
[0091] S330, acquiring the target state data from the state node in the case that the state node allows responding to the data acquisition request.
[0092] Specifically, in the embodiment, the target state data can be sent to the processing node when the state node allows the response data acquisition request. The processing node can also be fed back with the consent acquisition information, so that the processing node acquires the target state data from the state node based on the consent acquisition information.
[0093] In the above embodiments, the whole process of acquiring the target state data from the state node by the processing node is given, so that the acquisition process of the target state data is clearer. In addition, the mapping relationship is constructed in advance to determine the state node, so that the process of determining the state node is simpler, thereby improving the acquisition efficiency of the target state data and the efficiency of the transaction processing to a certain extent.
[0094] On the basis of the technical solutions of the above embodiments, the present application further provides an optional embodiment. In the optional embodiment, the transaction request includes transaction content, and in this case, the process of controlling the processing node to process the to-be-processed transaction based on the first state data and the second state data is introduced in detail.
[0095] Referring to Figure 4 The processing steps of the to-be-processed transaction include:
[0096] Start.
[0097] S410, it is judged whether the first state data and the second state data both satisfy the transaction request, if yes, S420 is executed, and if not, S430 is executed.
[0098] S420, the processing node is controlled to adjust the first state data and the second state data based on the transaction content, so as to process the to-be-processed transaction.
[0099] It can be understood that if the first state data and / or the second state data do not satisfy the transaction request, the transaction processing cannot be performed. Taking the transaction content of the to-be-processed transaction as an example, the account A transfers 100 yuan to the account B, if the first state data represents that the balance in the account A is less than 100 yuan, the transaction processing cannot be performed.
[0100] Optionally, in order to make the transaction processing more rigorous, the first state data and the second state data can also be verified in the embodiment, so as to determine whether the account of the transaction participant is in a frozen state, if yes, the transaction processing cannot be performed.
[0101] S430, the processing node is controlled to reject the execution of the transaction request.
[0102] In the above embodiments, the first state data and the second state data corresponding to the to-be-processed transaction are verified before the to-be-processed transaction is processed, and the to-be-processed transaction is processed when the first state data and the second state data are both verified, thereby improving the rigor of transaction processing.
[0103] It should be noted that after the first state data and the second data are adjusted, the adjusted first state data and second state data are stored in the processing node as active state data.
[0104] On the basis of the technical solutions of the above embodiments, the present application further provides an optional embodiment. In the optional embodiment, the transaction processing method provided by the present application is further supplemented.
[0105] Referring to the transaction processing method shown in Figure 5 The transaction processing method comprises the following steps:
[0106] S510, the first state data of the transaction initiator and the second state data of the transaction participant are stored in the processing node, and the first state data and the second state data satisfy the transaction request, and the processing node is controlled to adjust the first state data and the second state data based on the transaction content to process the to-be-processed transaction.
[0107] Specifically, in the present embodiment, the first state data of the transaction initiator and the second state data of the transaction participant are stored in the processing node, and the first state data and the second state data satisfy the transaction request, and the processing node is controlled to adjust the first state data and the second state data stored in the processing node based on the transaction content to process the to-be-processed transaction.
[0108] Correspondingly, after the first state data and the second state data are adjusted, the state adjustment instruction can also be sent to the state node corresponding to the transaction participant, so that the corresponding state node adjusts the recorded state data, thereby adjusting the state data stored in the state node to the latest data.
[0109] In the above embodiments, subsequent steps after the transaction processing is completed are given to ensure that the state data in the state node is the latest data.
[0110] On the basis of the technical solutions of the above embodiments, the present application further provides an optional embodiment. In the optional embodiment, the transaction processing method provided by the present application is further supplemented.
[0111] Referring to the transaction processing method shown in Figure 6A The transaction processing method comprises the following steps:
[0112] S601, obtaining a transaction request initiated by a transaction initiator;
[0113] The transaction request includes identification information of a transaction participant corresponding to a to-be-processed transaction; the transaction participant includes a transaction initiator and a transaction receiver.
[0114] S602, determining a processing node corresponding to the transaction request according to the identification information of the transaction initiator, and sending the transaction request to the processing node.
[0115] S603, controlling the processing node to determine whether the first state data and the second state data are stored therein; if yes, performing S610, and if not, performing S604.
[0116] S604, according to the storage condition of the state data corresponding to each transaction participant in the processing node, controlling the processing node to select a state node corresponding to a target transaction participant from at least two candidate state nodes corresponding to the processing node according to the identification information of the target transaction participant and the mapping relationship corresponding to the processing node.
[0117] It should be noted that in the D-MPT, the world state tree originally saving the blockchain state data is still logically an integral whole, but is divided into several parts:
[0118] The formal definition of the world state tree is as follows:
[0119]
[0120] In the formula, is the state tree in the memory of the miner node, which saves the top part of the state tree and tries to store active state data as much as possible; is the state subtree of the bottom part, which is called when the data volume is small; One server (i.e., one account) corresponds to one state node, and one state node corresponds to multiple ; represents the mapping relationship between the state prefix (the first several bytes of the state address) in the miner node and the state node, and the state node can be obtained through the address prefix; represents that the miner node can record the transaction execution, account update and other information of the blockchain system through the pre-write log.
[0121] In this embodiment, in order for the miner node to obtain inactive state data, it needs to access the state node, so the miner node also needs to save the mapping relationship between the state prefix of the state data and the state node:
[0122] ;
[0123] In the formula, the state prefix represents state data, The id represents a state node, and the corresponding state node can be searched for search data.
[0124] The state tree is horizontally divided, and the top layer of the state tree has only one state tree, while the bottom layer is divided into a large number of state sub-trees The state node can adaptively adjust the number of sub-trees it saves according to the configuration of the node. In order to facilitate adaptive adjustment, a state virtual node is introduced.
[0125] As Figure 6B shown is the content in a state node, a server corresponds to a state node, and the state node is mapped to k state virtual nodes according to its configuration, and the size of k can be adaptively adjusted according to the node, and each state virtual node has a fixed number of .
[0126] For state data, it is necessary to determine which state node to divide into, and when the data is needed, it should be obtained from which node. For this purpose, the present patent combines a consistent hash algorithm, and all and state virtual nodes are mapped to the same hash ring, and the range of the hash ring is from 0 to . When the data is divided, the address of the state prefix can be directly allocated, and the state virtual node is mapped through a hash function.
[0127] When the state node number of the state data is determined, the next node number along the hash ring can be found, and the node number obtained at this time is the state virtual node number. After obtaining the state node number and the address, the corresponding state data is sent to the state node for storage. In order to facilitate fast data search, after the data is divided, the is set in the miner node to save the mapping relationship between the state data and the state node.
[0128] S605, control the processing node to send a data acquisition request to the state node;
[0129] The data acquisition request is as follows:
[0130] S606, in the case that the state node allows to respond to the data acquisition request, control the processing node to acquire target state data from the state node;
[0131] The state data of the target transaction participant is not stored in the processing node. The target state data includes first state data of a transaction initiator, and / or second state data of a transaction receiver;
[0132] S607, the control processing node determines whether the first state data and the second state data both satisfy the transaction request; if yes, S608 is executed, and if no, S609 is executed;
[0133] S608, the first state data and the second state data are adjusted to process the to-be-processed transaction;
[0134] S609, the transaction request is rejected;
[0135] S610, the first state data of the transaction initiator and the second state data of the transaction participant are stored in the processing node, and the first state data and the second state data satisfy the transaction request, and the processing node adjusts the first state data and the second state data based on the transaction content to process the to-be-processed transaction;
[0136] S611, the state adjustment instruction is sent to the state node corresponding to the transaction participant to adjust the recorded state data by the corresponding state node.
[0137] Further, in order to make the above process clearer, the application also provides a specific operation embodiment of the processing node (i.e. the miner node) when performing a read operation:
[0138] 1. First, the miner node performing the transaction searches the local node for the ;
[0139] 2. If the required state data exists, the data update algorithm is called to update the leaf node state ;
[0140] 3. If the required data is not found, the corresponding state node number is obtained in , and a state request message is sent;
[0141] 4. The corresponding state data is obtained from the state node;
[0142] The formal definition of the state request message is as follows:
[0143] ;
[0144] 5. After receiving the state request message, the state node performs a search operation in the tree to as an input parameter, calls the search algorithm, and obtains the state data in the state sub-tree;
[0145] 6. After obtaining the account data , the state node generates witness data by a verification method;
[0146] 7. Finally, a request confirmation message is sent, which and witness data is sent to the miner node;
[0147] wherein the formal definition of the request confirmation message is as follows:
[0148] .
[0149] Further, it needs to be explained that in the present embodiment, as the system running time is prolonged, more users will join the blockchain system, and the blockchain data volume will also grow continuously. In the architecture, state data needs to be saved on the state node, and the state node memory may not be sufficient to store the growing data. Therefore, the system needs to be expanded, and a certain number of new nodes need to be added as state nodes to avoid the memory of the state node being exhausted, which leads to errors in the blockchain system, and therefore the scalability of the system needs to be ensured.
[0150] System expansion needs to add new state nodes to the system, that is, new machines are added to the architecture as components. The newly added state nodes will follow the following steps:
[0151] 1. According to the node hardware configuration, it is mapped into k state virtual nodes;
[0152] 2. Then these state virtual nodes are mapped to the hash ring;
[0153] 3. The data is re-divided into the corresponding nodes along the clockwise direction for storage;
[0154] 4. In the process of data redistribution, since multiple state virtual nodes are generated, multiple positions on the hash ring will be affected;
[0155] 5. A small part of the state data owned by the related nodes will be transferred to the new nodes, and there will be no situation of sudden large data transfer of a node.
[0156] In addition, the nodes in the blockchain public chain network can freely join and exit the network, and there are nodes with powerful hardware resources in the network to store all state data in memory. In this case, all data can be obtained from , and no disk I / O operation will be generated in data search; however, more node resources are limited and can only save part of the state data, and need to obtain the state data when executing some transactions; even some machines with poor performance, their resources are not enough to run the miner node, and can only save less state data, but these nodes also want to participate in the operation of the blockchain.
[0157] In this application, the system parameter settings can be adjusted to better adapt to the hardware device configuration according to the actual situation. The reserved layer number of the top part of the world state tree in the system is defined as , the space occupied by the top part is adjusted by modifying ; A 32-byte hash value is used to generate witness data, and the state sub-tree data is small, so a shorter hash value can be used to generate witness data without conflicts, which can reduce the size of data transmission in the network. The compression coefficient of witness data is defined as c, and the size of compressed witness data is reduced, thereby reducing the time of data transmission in the network.
[0158] By modifying the configuration parameters r and c of D-MPT, the system settings can be adjusted to adapt to different server configurations. For example: sufficient hardware resources, only need to get data from local memory, do not need to call remote state data application in transaction execution, can set the top layer reserved layer number r = + ∞, the top part is actually the entire state tree; or the hardware configuration of the miner node is poor, and the state node needs to be accessed frequently, which generates network overhead, if the compression coefficient c = 1, the witness data will not be compressed; if the compression coefficient c = 0, at this time, it is actually considered that all state nodes are trusted, and witness data does not need to be generated, only state data needs to be obtained. Adjusting the compression coefficient c will affect the data security of the miner node, and the server situation in the architecture can be selected for setting.
[0159] In addition to the parameter r, saving more active state data in the top layer can improve the hit rate of data and reduce the amount of network communication data. Therefore, in the ideal case, the number of accounts reserved in the top layer of D-MPT should be set according to the maximum available memory, and the modification of top layer data should be performed in the local memory of the node as much as possible.
[0160] It should be understood that although each step in the flowchart involved in each embodiment as described above is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in each embodiment as described above can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be executed in rotation or alternation with at least part of other steps or steps or stages in other steps.
[0161] Based on the same inventive concept, the embodiments of the present application further provide a transaction processing apparatus for implementing the transaction processing method described above. The implementation scheme for solving the problem provided by the apparatus is similar to the implementation scheme described in the above method, and therefore the specific limitations in one or more transaction processing apparatus embodiments provided below can refer to the limitations of the transaction processing method described above, which will not be repeated here.
[0162] In one exemplary embodiment, as shown in Figure 7 a transaction processing apparatus is provided, comprising: a request acquisition module 710, a processing node determination module 720, and a data acquisition module 730, wherein:
[0163] The request acquisition module 710 is configured to acquire a transaction request initiated by a transaction initiator; wherein the transaction request comprises identification information of a transaction participant corresponding to a to-be-processed transaction; the transaction participant comprises the transaction initiator and a transaction receiver;
[0164] The processing node determination module 720 is configured to determine a processing node corresponding to the transaction request according to the identification information of the transaction initiator, and send the transaction request to the processing node;
[0165] The data acquisition module 730 is configured to, in a case where the target state data is not stored in the processing node, control the processing node to acquire the target state data from a state node corresponding to the transaction participant; wherein the target state data comprises first state data of the transaction initiator, and / or second state data of the transaction receiver;
[0166] The first transaction processing module 740 is configured to control the processing node to process the to-be-processed transaction according to the first state data and the second state data.
[0167] In one embodiment, the data acquisition module 730 is specifically configured to, according to the storage condition of the state data of each transaction participant in the processing node, control the processing node to select a state node corresponding to the target transaction participant from at least two candidate nodes corresponding to the processing node according to the identification information of the target transaction participant, and acquire the target state data from the state node; wherein the state data of the target transaction participant is not stored in the processing node.
[0168] In one embodiment, the data acquisition module 730 is specifically configured to select the state node corresponding to the target transaction participant from at least two candidate state nodes corresponding to the processing node according to the identification information of the target transaction participant and a mapping relationship corresponding to the processing node.
[0169] In an embodiment, the data obtaining module 730 comprises a request sending unit configured to send a data obtaining request to the state node; and a data obtaining unit configured to obtain the target state data from the state node if the state node allows responding to the data obtaining request.
[0170] In an embodiment, the transaction request comprises transaction content; and correspondingly, the first transaction processing module comprises a first processing unit configured to control the processing node to adjust the first state data and the second state data based on the transaction content to process the to-be-processed transaction if the first state data and the second state data satisfy the transaction request; and a second processing unit configured to reject to execute the transaction request if the first state data and / or the second state data does not satisfy the transaction request.
[0171] In an embodiment, the transaction processing apparatus further comprises a second transaction processing module configured to control the processing node to adjust the first state data and the second state data based on the transaction content to process the to-be-processed transaction if the first state data and the second state data satisfy the transaction request, and the first state data and the second state data are stored in the processing node and belong to a transaction initiator and a transaction participant respectively; and send a state adjustment instruction to the state node corresponding to the transaction participant to adjust the recorded state data. Correspondingly, the first transaction module further comprises an instruction sending unit configured to send the state adjustment instruction to the state node corresponding to the transaction participant to adjust the recorded state data.
[0172] The above-mentioned modules in the transaction processing apparatus can be realized by software, hardware or combination thereof in whole or in part. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or stored in the memory in the computer device in software form to be called and executed by the processor to perform the operations corresponding to the above-mentioned modules.
[0173] In an exemplary embodiment, a computer device is provided, which can be a terminal, and the internal structure diagram thereof can be as shown in Figure 8The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The input / output interface of the computer device is configured to exchange information between the processor and external devices. The communication interface of the computer device is configured to perform wired or wireless communication with external terminals. The wireless communication can be achieved through WIFI, mobile cellular network, Near Field Communication (NFC) or other technologies. The computer program is executed by the processor to implement a transaction processing method. The display unit of the computer device is configured to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc.
[0174] Those skilled in the art can understand that, Figure 8 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0175] In one exemplary embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the following steps:
[0176] Obtaining a transaction request initiated by a transaction initiator; wherein the transaction request includes identification information of a transaction participant corresponding to a to-be-processed transaction; the transaction participant includes the transaction initiator and a transaction receiver;
[0177] According to the identification information of the transaction initiator, determining a processing node corresponding to the transaction request, and sending the transaction request to the processing node;
[0178] In a case where the target state data is not stored in the processing node, the processing node is controlled to acquire the target state data from a state node corresponding to the transaction participant; the target state data includes first state data of the transaction initiator and / or second state data of the transaction receiver.
[0179] The processing node is controlled to process the to-be-processed transaction according to the first state data and the second state data.
[0180] In an embodiment, the processor, when executing the computer program, further implements the following steps:
[0181] According to storage of the state data of each transaction participant in the processing node, the processing node is controlled to select, according to the identification information of the target transaction participant, a state node corresponding to the target transaction participant from at least two candidate nodes corresponding to the processing node, and acquire the target state data from the state node.
[0182] The state data of the target transaction participant is not stored in the processing node.
[0183] In an embodiment, the processor, when executing the computer program, further implements the following steps:
[0184] According to the identification information of the target transaction participant and the mapping relationship corresponding to the processing node, the processing node is controlled to select a state node corresponding to the target transaction participant from at least two candidate state nodes corresponding to the processing node.
[0185] In an embodiment, the processor, when executing the computer program, further implements the following steps:
[0186] The processing node is controlled to send a data acquisition request to the state node.
[0187] In a case where the state node allows the data acquisition request, the processing node is controlled to acquire the target state data from the state node.
[0188] In an embodiment, the processor, when executing the computer program, further implements the following steps:
[0189] In a case where the first state data and the second state data satisfy the transaction request, the processing node is controlled to adjust the first state data and the second state data based on the transaction content, so as to process the to-be-processed transaction.
[0190] In a case where the first state data and / or the second state data does not satisfy the transaction request, the processing node is controlled to reject the transaction request.
[0191] In an embodiment, the processor, when executing the computer program, further implements the following steps:
[0192] The first state data of the transaction initiator and the second state data of the transaction participant are stored in the processing node, and the first state data and the second state data meet the transaction request, and the processing node is controlled to adjust the first state data and the second state data based on the transaction content to process the to-be-processed transaction; and a state adjustment instruction is sent to the state node corresponding to the transaction participant to adjust the recorded state data.
[0193] In one embodiment, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the following steps:
[0194] A transaction request initiated by a transaction initiator is obtained; the transaction request includes identification information of a transaction participant corresponding to a to-be-processed transaction; the transaction participant includes the transaction initiator and a transaction receiver;
[0195] According to the identification information of the transaction initiator, a processing node corresponding to the transaction request is determined, and the transaction request is sent to the processing node;
[0196] In a case where the target state data is not stored in the processing node, the processing node is controlled to obtain the target state data from a state node corresponding to the transaction participant; the target state data includes first state data of the transaction initiator and / or second state data of the transaction receiver;
[0197] The processing node is controlled to process the to-be-processed transaction according to the first state data and the second state data.
[0198] In one embodiment, the computer program is executed by the processor to further implement the following steps:
[0199] According to the storage of the state data of each transaction participant in the processing node, the processing node is controlled to select a state node corresponding to a target transaction participant from at least two candidate nodes corresponding to the processing node according to the identification information of the target transaction participant, and obtain the target state data from the state node;
[0200] The state data of the target transaction participant is not stored in the processing node.
[0201] In one embodiment, the computer program is executed by the processor to further implement the following steps:
[0202] According to the identification information of the target transaction participant and the mapping relationship corresponding to the processing node, a state node corresponding to the target transaction participant is selected from at least two candidate state nodes corresponding to the processing node.
[0203] In one embodiment, the computer program is executed by the processor to further implement the following steps:
[0204] sending a data acquisition request to the state node;
[0205] acquiring the target state data from the state node in the case that the state node allows responding to the data acquisition request.
[0206] In one embodiment, the computer program, when executed by the processor, further implements the following steps:
[0207] controlling the processing node to adjust the first state data and the second state data based on the transaction content to process the to-be-processed transaction in the case that the first state data and the second state data satisfy the transaction request;
[0208] rejecting to execute the transaction request in the case that the first state data and / or the second state data does not satisfy the transaction request.
[0209] In one embodiment, the computer program, when executed by the processor, further implements the following steps:
[0210] controlling the processing node to adjust the first state data and the second state data based on the transaction content to process the to-be-processed transaction in the case that the first state data and the second state data satisfy the transaction request; sending a state adjustment instruction to the state node corresponding to the transaction participant to adjust the recorded state data.
[0211] In one embodiment, a computer program product is provided, comprising a computer program which, when executed by the processor, implements the following steps:
[0212] acquiring a transaction request initiated by a transaction initiator; wherein the transaction request comprises identification information of a transaction participant corresponding to a to-be-processed transaction; the transaction participant comprises the transaction initiator and a transaction receiver;
[0213] determining a processing node corresponding to the transaction request according to the identification information of the transaction initiator, and sending the transaction request to the processing node;
[0214] controlling the processing node to acquire target state data from a state node corresponding to the transaction participant in the case that the target state data is not stored in the processing node; wherein the target state data comprises first state data of the transaction initiator and / or second state data of the transaction receiver;
[0215] controlling the processing node to process the to-be-processed transaction according to the first state data and the second state data.
[0216] In one embodiment, the computer program, when executed by the processor, further implements the following steps:
[0217] According to the storage of the state data corresponding to each transaction participant in the processing node, the processing node selects the state node corresponding to the target transaction participant from at least two candidate nodes corresponding to the processing node according to the identification information of the target transaction participant, and obtains the target state data from the state node.
[0218] Wherein, the state data of the target transaction participant is not stored in the processing node.
[0219] In one embodiment, the computer program, when executed by the processor, further implements the following steps:
[0220] According to the identification information of the target transaction participant, and the mapping relationship corresponding to the processing node, the state node corresponding to the target transaction participant is selected from at least two candidate state nodes corresponding to the processing node.
[0221] In one embodiment, the computer program, when executed by the processor, further implements the following steps:
[0222] Send a data acquisition request to the state node;
[0223] In the case that the state node allows to respond to the data acquisition request, the target state data is obtained from the state node.
[0224] In one embodiment, the computer program, when executed by the processor, further implements the following steps:
[0225] In the case that the first state data and the second state data satisfy the transaction request, the processing node adjusts the first state data and the second state data based on the transaction content to process the to-be-processed transaction.
[0226] In the case that the first state data and / or the second state data does not satisfy the transaction request, the transaction request is rejected.
[0227] In one embodiment, the computer program, when executed by the processor, further implements the following steps:
[0228] In the case that the first state data and the second state data satisfy the transaction request, the processing node adjusts the first state data and the second state data based on the transaction content to process the to-be-processed transaction; and sends a state adjustment instruction to the state node corresponding to the transaction participant, so that the corresponding state node adjusts the recorded state data.
[0229] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant regulations.
[0230] It can be understood by those skilled in the art that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, it can include the processes of the above-mentioned embodiments of each method. Any reference to memory, database or other medium used in each embodiment provided by the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in each embodiment provided by the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in each embodiment provided by the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., without being limited thereto.
[0231] Any technical features in the above embodiments can be combined, and for the sake of brevity, not all possible combinations are described above, however, any combination of the technical features is deemed to be within the scope of the present application.
[0232] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the patent scope of the present application. It should be pointed out that, for ordinary skilled persons in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A transaction processing method, characterized in that, The method includes: Obtain a transaction request initiated by the transaction initiator; wherein, the transaction request includes the identification information of the transaction participants corresponding to the transaction to be processed; the transaction participants include the transaction initiator and the transaction receiver; Based on the identifier information of the transaction initiator, determine the processing node corresponding to the transaction request, and send the transaction request to the processing node; If the processing node does not store the target state data, the processing node is controlled to obtain the target state data from the state node corresponding to the transaction participant; wherein, the target state data includes the first state data of the transaction initiator and / or the second state data of the transaction receiver. When the target state data includes the first state data and the second state data, the processing node is controlled to process the transaction to be processed based on the first state data and the second state data.
2. The method according to claim 1, characterized in that, The step of controlling the processing node to obtain the target state data from the state nodes corresponding to the transaction participants includes: Based on the storage status data of each transaction participant in the processing node, the processing node is controlled to select the status node corresponding to the target transaction participant from at least two candidate nodes corresponding to the processing node according to the identification information of the target transaction participant, and obtain the target status data from the status node. The status data of the target transaction participants is not stored in the processing node.
3. The method according to claim 2, characterized in that, The step of selecting the status node corresponding to the target transaction participant from at least two candidate nodes corresponding to the processing node based on the identification information of the target transaction participant includes: Based on the identification information of the target transaction participant and the mapping relationship corresponding to the processing node, the state node corresponding to the target transaction participant is selected from at least two candidate state nodes corresponding to the processing node.
4. The method according to claim 2, characterized in that, Obtaining the target state data from the state node includes: Send a data acquisition request to the status node; If the status node allows the response to the data acquisition request, the target status data is acquired from the status node.
5. The method according to any one of claims 1-4, characterized in that, The transaction request includes transaction content; correspondingly, the control of the processing node processes the transaction to be processed based on the first state data and the second state data, including: If the first state data and the second state data satisfy the transaction request, the control node adjusts the first state data and the second state data based on the transaction content to process the transaction to be processed. If the first state data and / or the second state data do not satisfy the transaction request, the transaction request is rejected.
6. The method according to any one of claims 1-4, characterized in that, The method further includes: The processing node stores the first state data of the transaction initiator and the second state data of the transaction participants. When the first state data and the second state data satisfy the transaction request, the processing node is controlled to adjust the first state data and the second state data based on the transaction content in order to process the transaction to be processed. Accordingly, after adjusting the first state data and the second state data, the method further includes: The status adjustment instruction is sent to the status node corresponding to the transaction participant so that the corresponding status node can adjust the recorded status data.
7. A transaction processing apparatus, characterized in that, The device includes: The request acquisition module is used to acquire transaction requests initiated by the transaction initiator; wherein, the transaction request includes the identification information of the transaction participants corresponding to the transaction to be processed; the transaction participants include the transaction initiator and the transaction receiver; The processing node determination module is used to determine the processing node corresponding to the transaction request based on the identification information of the transaction initiator, and send the transaction request to the processing node; The data acquisition module is used to control the processing node to acquire the target state data from the state node corresponding to the transaction participant when the processing node does not store the target state data; wherein the target state data includes the first state data of the transaction initiator and / or the second state data of the transaction receiver. The first transaction processing module is configured to control the processing node to process the transaction to be processed based on the first state data and the second state data when the target state data includes the first state data and the second state data.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data processing method and device
CN110045912A
Transaction processing method, device and system and storage medium
CN111143040A