A blockchain transaction submission, editing and query method based on time series attributes

By adding timing attributes to transaction data in the blockchain and using fixed balance and temporary balance collection mechanisms, the permanent problem of illegal transactions in the blockchain is solved, the editing and query of transaction data is realized, and the blockchain is maintained Security and the effectiveness of the transaction chain.

CN113656504BActive Publication Date: 2024-11-19WUHAN UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110965651.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-23
Publication Date
2024-11-19
Estimated Expiration
2041-08-23

AI Technical Summary

Technical Problem

The permanent negative impact of human operation errors or malicious illegal transactions in the blockchain has been caused by permanent negative impacts. The existing transaction editing plan uses cryptography to replace the block content, which poses security risks and may affect the effectiveness of the transaction chain.

Method used

Using blockchain transaction submission, editing and query methods based on timing attributes, by adding timing attributes to transaction data, building transaction data, consensus sorting and storing, recording the timing attributes of transactions, and maintaining the correct timing relationship during editing. Use fixed balance and temporary balance collection mechanisms to set the editable time interval Δt.

Benefits of technology

It realizes editing and querying transaction data, maintains the security of the blockchain and the effectiveness of the transaction chain, avoids the inability to verify historical data, solves the problem of strong context-related transaction type data editing, and rationalizes the historical transactions. edit.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113656504B_ABST
    Figure CN113656504B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for submitting, editing and querying blockchain transactions based on timing attributes, the transaction method comprising: adding timing attributes to evidence type data and transaction type data according to a state database to construct transaction data; performing consensus sorting on the transaction data containing timing attributes, packaging them into blocks, and storing them on a blockchain; recording the block number of each transaction after consensus sorting and the order in the block as the timing attributes of the transaction according to the packaged result; the submitting node updates the state database according to the latest state after each transaction is executed; the state database includes the latest state corresponding to each KEY and the position of the state corresponding to the exchange in the blockchain, i.e., the timing attributes. The present invention redesigns the blockchain transaction data structure, and the client node performs chain retrieval through the timing attributes, can skip invalid historical transactions, and obtain all correct historical transaction records for the client node.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information technology, and in particular to a method for submitting, editing and querying blockchain transactions based on time series attributes. Background Art

[0002] Blockchain technology can store data in the form of transactions in a blockchain database, and it has the characteristics of decentralization, immutability, and openness and transparency. However, as a distributed database, there must be illegal transactions in the blockchain due to human operational errors or malicious submissions. These illegal transactions can have permanent negative effects with the help of the transparency and immutability of the blockchain. For example: malicious nodes upload false rumor information to the chain, and after consensus and other processes, this information is finally permanently stored on the blockchain, and all nodes can access it and are thus harmed by these bad information. In the existing schemes for editing blockchain transactions, cryptographic methods are mostly used to directly replace the block content while ensuring the immutability of the block, which will result in the holder of the key being able to modify the block data at will without modifying the evidence, causing security risks. In addition, the editing of transaction type data not only involves the edited transaction data itself, but also changes the value distribution system of subsequent transactions in the blockchain, which may "create" or "eliminate" a certain amount of currency out of thin air, thereby affecting the effectiveness of the entire blockchain transaction chain. Summary of the invention

[0003] In order to overcome the deficiencies of the above technologies, the present invention provides a blockchain transaction submission, editing and query method based on time series attributes. The present invention mainly targets the non-editable characteristics of blockchain data, and adopts a new transaction submission method to realize the editing of transaction data. Therefore, the technical effects achieved by the present invention are all for "transaction data editing", and the transaction submission method proposed by the present invention serves transaction editing, while the transaction query method is to reflect the results of transaction editing.

[0004] The technical solution adopted by the present invention to overcome the technical problems is:

[0005] A blockchain transaction submission method based on time series attributes, applied to a blockchain sorting node and a submission node, comprises the following steps:

[0006] S101. According to the state database, add time series attributes to the evidence type data and the transaction type data to construct the transaction data;

[0007] S102, sorting the transaction data containing time sequence attributes by consensus, packaging them into blocks, and storing them on the blockchain; based on the packaging results, recording the block number of each transaction after consensus sorting and the order of each transaction in the block as the time sequence attribute of the transaction;

[0008] S103. The submitting node updates the state database according to the latest state after each transaction is executed; the state database includes the latest state corresponding to each KEY and the position of the transaction corresponding to the state in the blockchain, that is, the timing attribute.

[0009] Furthermore, in step S101, a corresponding timing attribute is set for the transaction data according to the latest state of the KEY value stored in the state database, and the timing attribute is the storage position of the predecessor transaction corresponding to the target KEY value in the blockchain, wherein the predecessor transaction is the previous valid transaction that has the same KEY value as the target transaction and is earlier in the time series.

[0010] Furthermore, in step S101, the method of adding a time series attribute to the evidence type data is as follows:

[0011] Before storing transaction data, the state database must be searched to check the latest state of the KEY corresponding to the transaction. The time series attributes in the state are regarded as the storage location of the previous transaction in the blockchain.

[0012] Furthermore, in step S101, the method of adding time series attributes to transaction type data is as follows:

[0013] The KEY value corresponding to the transaction type data includes the sender and receiver of the transaction, and the timing attributes include the storage location of the sender's corresponding front-end exchange in the blockchain and the storage location of the receiver's corresponding front-end exchange in the blockchain;

[0014] Before constructing transaction data, transaction type data first needs to search the status database to determine whether the fixed balance of the sender's corresponding status meets the transfer requirements: if it does not meet the transfer requirements, the transaction data cannot be constructed and the transaction failure result is directly returned; if it meets the transfer requirements, the fixed balance of the sender specified by the client is transferred to the receiver's temporary balance set according to the client input, and the timing information of the corresponding previous transactions of the sender and the receiver is recorded in the transaction and submitted to the chain.

[0015] Further, regarding fixed balance and temporary balance collections:

[0016] The state of the account of transaction type data is represented as a set of fixed balances and temporary balances, and a fixed time period Δt is set, where Δt is the time period from when each transaction is submitted to the blockchain to when it cannot be edited;

[0017] Before submitting transaction type data, first check the balance status of the sender and the receiver according to the status database, and update the temporary balance that meets the conditions to the fixed balance. The condition must be that the submission time of the transaction corresponding to the temporary balance plus the time period Δt is greater than or equal to the submission time of the current transaction; the sender can only use the fixed balance when transferring money, and the receiver must put the balance into the temporary balance set after the Δt time period after accepting the transfer;

[0018] The time period Δt is dynamically adjusted according to the frequency of transactions in the actual application scenario; each element in the temporary balance set represents the balance accepted by the recipient for each transaction plus the timestamp corresponding to the transaction.

[0019] Furthermore, in step S102, recording the time series attributes and updating the state database includes:

[0020] After the transaction is packaged by the sorting node through consensus, all transactions in the block are traversed, and the storage location of each transaction in the blockchain is recorded, that is, the timing attribute corresponding to the transaction; the packaged block is sent to the submission node for verification, and the status of the corresponding KEY in the status database is updated according to the status and timing attributes corresponding to the transaction.

[0021] The present invention also discloses a blockchain transaction editing method based on the above-mentioned time series attribute, which is applied to a blockchain client node and includes the steps of:

[0022] S201, receiving a transaction editing request sent by a client node, wherein the editing request at least includes: a KEY value of a target historical transaction edited by the client node, parameters of the target historical transaction, a timestamp, and edited transaction parameters;

[0023] S202, based on the historical transaction parameters input by the client node, chain search is performed using the state data and the timing attributes of the previous transaction saved in the transaction as indexes;

[0024] S203, using the timing attributes of the target historical transaction corresponding to the previous transaction and the modified transaction parameters as input to construct new transaction data and submit it;

[0025] S204. Deserialize all historical transactions on the retrieval path when performing chain search with timing attributes, record the transaction metadata and enter the transaction pool. After the modified transaction is correctly submitted, submit the transaction in the transaction pool again in the timing order to maintain the correct timing relationship.

[0026] Further, in step S202, the state database is searched according to the KEY value sent by the client node to confirm whether the correct target KEY value and state exist:

[0027] If the correct KEY value and status exist, search through the time series attributes in the status to find the target transaction metadata and reconstruct the transaction subtree;

[0028] If the target KEY value does not exist or the target KEY value exists but the end bit in the corresponding status shows that the KEY value has been logically deleted, it is considered that the historical transaction corresponding to the KEY value has been deleted and cannot be edited, and failure is returned.

[0029] The present invention also discloses a blockchain transaction query method based on the above-mentioned time series attribute, which is applied to a blockchain node and includes the steps of:

[0030] S301, receiving a query request sent by a client node, wherein the query request at least includes: querying a KEY value corresponding to a historical transaction;

[0031] S302, searching the state database according to the KEY value corresponding to the historical transaction of the target query, and obtaining the position of the transaction corresponding to the latest state of the KEY value according to the latest state, that is, the time sequence attribute of the preceding transaction;

[0032] S303. Obtain the corresponding block according to the timing attribute, deserialize the block and parse the transaction metadata according to the position of the transaction in the block, and then further query according to the timing attribute of the preceding transaction included in the transaction;

[0033] S304. Record the historical snapshot of the KEY value contained in the transaction, that is, the historical status, according to the queried transaction metadata; until the time series attribute in the transaction is empty, return all historical records to the client node.

[0034] Further, in step S302, the state database is searched according to the KEY value sent by the client node to confirm whether the correct target KEY value and state exist:

[0035] If the correct KEY value and status exist, the corresponding transaction metadata is retrieved through the timing attributes in the status, and recursively retrieved through the timing attributes in the transaction;

[0036] If the target KEY value does not exist or the target KEY value exists but the end bit in the corresponding status shows that the KEY value has been logically deleted, an empty set is directly returned to the client and the query ends.

[0037] The beneficial effects of the present invention are:

[0038] 1. The blockchain transaction submission, editing and query method based on timing attributes of the present invention divides blockchain data into two data types, namely, evidence storage and transaction types, and redesigns the underlying data structure respectively; according to the new data structure, the state database is checked to generate transaction data containing the timing attributes of the preceding transaction, where the preceding transaction is the previous valid transaction containing the same KEY as the target transaction; after the sorting node packages the transaction data to generate a block, the timing attributes are recorded according to the block number of the block where each transaction data is located and the storage location of the transaction data in the block; after the submission node verifies that the transaction is passed, the state database is updated according to the added timing attributes, and the client node can query the storage location of the transaction corresponding to the latest state of the KEY value through the timing attributes corresponding to the uniquely identified KEY value; the node performs chain retrieval according to the timing attributes by providing specific parameters of the target historical transaction, and stores the historical transactions on the retrieval path into the transaction pool; the timing attributes in the modified transaction data are set to the same value as the target historical transaction, and the transaction data in the transaction pool are submitted again in sequence to maintain a complete chain structure; the client node performs chain retrieval through the timing attributes, skips invalid historical transactions, and obtains all correct historical transaction records for the client node.

[0039] 2. The blockchain transaction query method based on time series attributes described in the present invention retains the original query interface of the blockchain, retains the evidence of erroneous transactions, and avoids the inability to verify historical data after editing.

[0040] 3. The blockchain transaction editing method based on time series attributes described in the present invention solves the problem of editing transaction type data with strong context correlation, reconstructs the transaction tree with the target historical transaction as the root node, and ensures the validity of subsequent transactions; and, in view of the large-scale transaction resubmission that may be caused by the editing of transaction type data, a fixed balance and temporary balance collection mechanism is set, and an editable time interval Δt is set, so that the editing of historical transactions is more reasonable. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 This is a flow chart of a blockchain transaction submission method based on timing attributes according to an embodiment of the present invention.

[0042] Figure 2 This is a flowchart of a blockchain transaction editing method based on time series attributes according to an embodiment of the present invention.

[0043] Figure 3 This is a flowchart of a blockchain transaction query method based on time series attributes according to an embodiment of the present invention. DETAILED DESCRIPTION

[0044] In order to facilitate those skilled in the art to better understand the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The following is only exemplary and does not limit the protection scope of the present invention.

[0045] Embodiment 1,

[0046] This embodiment provides a blockchain transaction submission method based on time series attributes, such as Figure 1 As shown, the submission method is applied to the blockchain sorting node and the submission node, including the steps of:

[0047] S101. According to the state database, add time series attributes to different types of transaction data to construct transaction data.

[0048] In this embodiment, different types of transaction data are divided into evidence type data and transaction type data, and time series attributes are added for these two different types of data. For complex transaction data corresponding to multiple KEY value states, it can be considered as multiple evidence text data corresponding to a single KEY; for transaction data involving more than two parties, it can also be considered as a combination of multiple two-party transactions and split.

[0049] Furthermore, transaction type data is a context-sensitive transaction type. Editing historical data may change the internal transaction logic flow and value distribution system, thereby "creating" or "consuming" a certain amount of cryptocurrency out of thin air, causing subsequent transactions to become invalid. All text-recorded data other than transaction type data are collectively referred to as evidence type data.

[0050] In step S101, a corresponding time series attribute is set for the transaction data according to the latest state of the KEY value stored in the state database, and the time series attribute is the storage position of the predecessor transaction corresponding to the target KEY value in the blockchain, wherein the predecessor transaction is the previous valid transaction that has the same KEY value as the target transaction and is earlier in the time series.

[0051] The first method is to add time series attributes to the evidence type data as follows:

[0052] Before storing transaction data, the state database must be searched to check the latest state of the KEY corresponding to the transaction. The time series attributes in the state are regarded as the storage location of the previous transaction in the blockchain.

[0053] The second method of adding time series attributes to transaction type data is as follows:

[0054] The KEY value corresponding to the transaction type data includes the sender and receiver of the transaction, and the timing attributes include the storage location of the sender's corresponding front-end exchange in the blockchain and the storage location of the receiver's corresponding front-end exchange in the blockchain;

[0055] Before constructing transaction data, transaction type data first needs to search the status database to determine whether the fixed balance of the sender's corresponding status meets the transfer requirements: if it does not meet the transfer requirements, the transaction data cannot be constructed and the transaction failure result is directly returned; if it meets the transfer requirements, the fixed balance of the sender specified by the client is transferred to the receiver's temporary balance set according to the client input, and the timing information of the corresponding previous transactions of the sender and the receiver is recorded in the transaction and submitted to the chain.

[0056] Specifically, the state database is searched according to the KEY value included in the input parameter provided by the client node to check whether the KEY value exists in the state database:

[0057] 1. If it exists, check whether the end bit in its state is ∅. If both the KEY value exists and the end bit is ∅, assign the timing attribute of the corresponding previous transaction in the state to the transaction, which is recorded as the PRE field;

[0058] 2. If the target KEY value does not exist, it is considered that the KEY value corresponding to the transaction is on the chain for the first time, and the previous transaction corresponding to the KEY value is empty, so the timing attribute corresponding to the transaction is also set to empty;

[0059] 3. If the KEY value exists but the end bit is the timing attribute of a transaction, the KEY value is considered to be logically deleted in the transaction corresponding to the end bit, and the previous transaction corresponding to the transaction is also considered to be empty, and the process described in the above second case (that is, the case where the target KEY value does not exist) is executed.

[0060] In this embodiment, for transaction type data, the corresponding KEY value, i.e., the transaction sender account and the transaction receiver account, is considered to be permanent. Therefore, unlike the stored text transaction data, the transaction type data cancels the timing attribute corresponding to the end bit and only retains the start bit. The start bit represents the timing attribute corresponding to the preceding transaction, and the end bit represents the position of the corresponding transaction in the blockchain when the state corresponding to the KEY value is deleted. If the end bit is ∅, it is considered that the transaction has not been deleted.

[0061] Furthermore, for transaction type data, the transaction is assigned the timing attributes of the previous transaction in the KEY value corresponding to the sender and receiver accounts, which are recorded as SAI (sender account index) and RAI (receiver account index). At the same time, for subsequent editing operations, for transaction type data, the balance is changed to a fixed balance plus a temporary balance set.

[0062] Specifically, a fixed time period Δt is set, which is the time period from when each transaction is submitted to the blockchain to when it cannot be edited. Each Δt corresponds to an independent blockchain application environment, and the size of Δt is dynamically adjusted according to the frequency of transactions in the actual application scenario. The time period Δt must satisfy that the time spent on all transactions submitted in the blockchain network within the time period of Δt is within an acceptable range. When there are more transactions submitted in the entire blockchain network per unit time, Δt can be appropriately reduced; conversely, when there are fewer transactions submitted in the blockchain network per unit time, Δt can be appropriately increased. This is to reduce storage resource consumption as much as possible when editing historical transactions and reconstructing transaction links later, while ensuring that there are as many editable historical transactions as possible.

[0063] Furthermore, based on the input of the client node, the status of the KEY values ​​corresponding to the sender and receiver accounts is checked. If the correct sender and receiver exist, the temporary balance set is traversed, and the temporary balance that meets the conditions in the account is converted into a fixed balance of the account. The transfer is performed according to the transfer amount in the input parameters, and the transaction is constructed and simulated.

[0064] Specifically, for all transactions in the temporary balance that satisfy the transaction submission time plus the specified time period Δt greater than or equal to the current transaction submission time, they are transferred to the fixed balance. When transferring transactions, the sender can only spend the currency in the fixed balance, and the receiver will also deposit the amount in the temporary balance set in the form of a temporary balance after receiving the currency. Among them, each element in the temporary balance set represents the balance accepted by the receiver for each transaction plus the timestamp corresponding to the transaction.

[0065] S102. Consensus-sort the transaction data containing timing attributes, package them into blocks, and store them on the blockchain; based on the packaged results, record the block number of each transaction after consensus sorting and the order within the block as the timing attributes of the transaction.

[0066] In this embodiment, recording the timing attributes and updating the state database includes: after the transaction is packaged by the sorting node after consensus, traversing all transactions in the block, recording the storage location of each transaction in the blockchain, that is, the timing attribute corresponding to the transaction; the packaged block is sent to the submission node for verification, and the state of the corresponding KEY in the state database is updated according to the state and timing attribute corresponding to the transaction.

[0067] Specifically, the endorsement node simulates the execution based on the input parameters provided in the client node, updates the latest status of the corresponding KEY value in the transaction to the status after the transaction is executed, and updates the corresponding write set.

[0068] Furthermore, the transaction containing the transaction execution result (i.e. the latest write set) is sent to the sorting node, which sorts it according to the preset consensus strategy. The block is generated after reaching the threshold according to the preset block size or block time.

[0069] Furthermore, all transactions in a block are traversed, and the timing attributes corresponding to the transaction are recorded according to the block number obtained after the block is generated and the position of each transaction in the block. The write set of the corresponding KEY value is updated according to the timing attributes.

[0070] Furthermore, the block is distributed to the commit node in the blockchain network through the gossip protocol. The commit node updates the latest state in the state database corresponding to the KEY value according to the write set contained in each transaction. The latest state includes the text data or balance corresponding to the KEY value, and the timing attributes corresponding to the transaction. It is worth mentioning that after updating the state database, the transaction becomes the previous transaction corresponding to the KEY value.

[0071] S103. The submitting node updates the state database according to the latest state after each transaction is executed; the state database includes the latest state corresponding to each KEY and the position of the transaction corresponding to the state in the blockchain, that is, the timing attribute.

[0072] Embodiment 2,

[0073] This embodiment discloses a blockchain transaction editing method based on the time series attribute described in Embodiment 1, such as Figure 2 As shown, the editing method is applied to the blockchain client node, including the steps of:

[0074] S201. Receive a transaction editing request sent by a client node, wherein the editing request at least includes: a KEY value of a target historical transaction edited by the client node, parameters of the target historical transaction, a timestamp, and edited transaction parameters.

[0075] S202: Based on the historical transaction parameters input by the client node, a chain search is performed using the state data and the timing attributes of the previous transaction saved in the transaction as indexes.

[0076] In step S202, the state database is searched according to the KEY value sent by the client node to confirm whether the correct target KEY value and state exist:

[0077] If the correct KEY value and status exist, search through the time series attributes in the status to find the target transaction metadata and reconstruct the transaction subtree;

[0078] If the target KEY value does not exist or the target KEY value exists but the end bit in the corresponding status shows that the KEY value has been logically deleted (that is, the end bit represents the timing attribute of a transaction), the historical transaction corresponding to the KEY value is considered to have been deleted and cannot be edited, and failure is returned.

[0079] In particular, for transaction type data, the editing operation can only be performed if the timestamp of the target transaction plus a specific time period Δt is less than the current time. This is to avoid reconstructing too many subsequent transactions; the subsequent transactions refer to all historical transactions that are affected by the target transaction and have a later time series.

[0080] Specifically, the target transaction data is found and the transaction subtree is reconstructed, including: finding the location of the corresponding block through the timing attribute of the previous transaction corresponding to the KEY value in the state database and deserializing the transaction metadata, and comparing it with the input and timestamp of the target transaction provided by the client node. If the match is successful, the transaction is considered to be the target transaction, and the timing attribute corresponding to the transaction and the write set of the KEY value corresponding to the transaction are recorded, and a new transaction is constructed together with the modified transaction parameters for submission; if the match is unsuccessful and the timing attribute in the transaction is not empty, recursively indexing according to the timing attribute in the transaction until the target transaction is matched, and recording the transaction metadata on the index path to the transaction pool; the transaction pool contains all transactions affected by the editing operation, which need to be submitted again in chronological order to maintain the correctness and integrity of the transaction link.

[0081] In particular, if the index is recursively performed according to the time series attribute until the time series attribute of the last transaction indexed is empty, it means that the target transaction cannot be found and the editing operation cannot be performed, and failure is also returned at this time.

[0082] S203: Use the timing attributes of the target historical transaction corresponding to the previous transaction and the modified transaction parameters as input to construct new transaction data and submit it.

[0083] S204. Deserialize all historical transactions on the retrieval path when performing chain search with timing attributes, record the transaction metadata and enter the transaction pool. After the modified transaction is correctly submitted, submit the transaction in the transaction pool again in the timing order to maintain the correct timing relationship.

[0084] In step S204, the transaction pool is updated according to the search path to reconstruct the transaction subtree. For transaction type data, editing historical transactions will not only affect all transactions on the search path, but also all transactions corresponding to accounts that have had direct or indirect transaction transfers with the sender and receiver of the target transaction. Therefore, for the editing of financial transfer transactions, all affected subsequent transactions after the target transaction need to be added to the transaction pool. For example, the target transaction includes sender account A and receiver account B, and account B subsequently conducted a transaction with account C, and account C subsequently conducted a transaction with account D, then all subsequent transactions corresponding to accounts A, B, C, and D are subsequent transactions of the target transaction.

[0085] Furthermore, the transaction subtree is reconstructed according to the transaction pool. All transaction metadata in the transaction pool are traversed in chronological order, the input parameters in the transaction metadata are recorded, and the transaction is submitted again in order using the input parameters. Before the transaction submission in the transaction pool is completed, the transaction with the same KEY value in the transaction pool cannot be submitted to ensure the reconstruction of the transaction subtree in the correct order. This operation can effectively ensure that when editing historical transactions, the value circulation and record order in the original blockchain will not be destroyed, the currency will not be generated or "consumed" out of thin air, and the original state change process will not be destroyed. In addition, the erroneous historical transaction vouchers can be retained for query to prevent malicious editing of historical transactions.

[0086] In addition, the editing operation is not limited to updating the target historical transaction, but also includes deleting the historical transaction data. Here, the deletion operation of the historical transaction data can be considered as a special update operation. For general evidence type data, the content corresponding to the target historical transaction data can be updated to empty; for transaction type data, the transfer amount of the target transaction is updated to zero.

[0087] Embodiment 3,

[0088] This embodiment discloses a blockchain transaction query method based on the time series attribute described in Embodiment 1, and the query is applied to the blockchain node. The query method described in this embodiment queries the transaction itself after the transaction is submitted to the blockchain; if the transaction is edited as described in Embodiment 2 after submission, the query method described in this embodiment queries the latest transaction content after the editing in Embodiment 2.

[0089] like Figure 3 As shown, the query method comprises the steps of:

[0090] S301. Receive a query request sent by a client node, where the query request at least includes: querying a KEY value corresponding to a historical transaction.

[0091] S302, searching the state database according to the KEY value corresponding to the target query historical transaction, and obtaining the position of the transaction corresponding to the latest state according to the latest state, that is, the time sequence attribute of the preceding transaction.

[0092] In this embodiment, in step S302, the state database is searched according to the KEY value sent by the client node to confirm whether the correct target KEY value and state exist:

[0093] If the correct KEY value and status exist, the corresponding transaction metadata is retrieved through the timing attributes in the status, and recursively retrieved through the timing attributes in the transaction;

[0094] If the target KEY value does not exist or the target KEY value exists but the end bit in the corresponding status shows that the KEY value has been logically deleted (that is, the end bit represents the timing attribute of a transaction), an empty set is directly returned to the client and the query ends.

[0095] Furthermore, the blockchain transaction metadata is persistently stored in the form of a byte array on disk. The block where the transaction is located is located through the state and timing attributes in the transaction. The byte segment of the entire block can be calculated by indexing the header pointer and offset of each blockchain recorded in the database.

[0096] Furthermore, the corresponding byte array of the block is deserialized, and the transaction metadata is obtained by the serial number of the transaction in the block in the timing attribute, that is, the sequential position after deserialization. The above operation is recursively performed according to the timing attribute in the transaction until the timing attribute in the transaction is empty. At this time, all valid historical transaction data corresponding to the KEY value has been retrieved, and the result set is returned to the client node.

[0097] S303, obtaining the corresponding block according to the timing attribute, deserializing the block and parsing the transaction metadata according to the position of the transaction in the block, and then further querying according to the timing attribute of the preceding transaction included in the transaction.

[0098] S304. Record the historical snapshot of the KEY value contained in the transaction, that is, the historical status, according to the queried transaction metadata; until the time series attribute in the transaction is empty, return all historical records to the client node.

[0099] The above only describes the basic principles and preferred embodiments of the present invention. Those skilled in the art may make many changes and improvements based on the above description, and these changes and improvements should fall within the protection scope of the present invention.

Claims

1. A blockchain transaction submission method based on time series attributes, characterized in that: Applied to blockchain sorting nodes and submission nodes, including the following steps: S101. According to the state database, add time series attributes to the evidence type data and the transaction type data to construct the transaction data; According to the latest state of the KEY value stored in the state database, a corresponding time series attribute is set for the transaction data, wherein the time series attribute is the storage position of the predecessor transaction corresponding to the target KEY value in the blockchain, wherein the predecessor transaction is the previous valid transaction that has the same KEY value as the target transaction and is earlier in the time series; The method to add time series attributes to evidence type data is as follows: Before constructing transaction data with evidence-type data, you first need to search the state database to check the latest state of the KEY corresponding to the transaction. The time series attribute in the state is regarded as the storage location of the previous transaction in the blockchain. The method to add time series attributes to transaction type data is as follows: The KEY value corresponding to the transaction type data includes the sender and receiver of the transaction, and the timing attributes include the storage location of the sender's corresponding front-end exchange in the blockchain and the storage location of the receiver's corresponding front-end exchange in the blockchain; Before constructing transaction data, the state database must be searched to determine whether the fixed balance of the sender's corresponding state meets the transfer requirements. If the transfer requirements are not met, the transaction data cannot be constructed and the transaction failure result is directly returned. If the transfer requirements are met, the fixed balance of the sender's specified amount is transferred to the receiver's temporary balance set according to the client input, and the timing information of the sender and receiver's corresponding previous transactions is recorded in the transaction and submitted to the chain. S102, sorting the transaction data containing time sequence attributes by consensus, packaging them into blocks, and storing them on the blockchain; based on the packaging results, recording the block number of each transaction after consensus sorting and the order of each transaction in the block as the time sequence attribute of the transaction; S103. The submitting node updates the state database according to the latest state after each transaction is executed; the state database includes the latest state corresponding to each KEY and the position of the transaction corresponding to the state in the blockchain, that is, the timing attribute.

2. The submission method according to claim 1, characterized in that: About fixed balance and temporary balance collection: The state of the account of transaction type data is represented as a set of fixed balances and temporary balances, and a fixed time period Δt is set, where Δt is the time period from when each transaction is submitted to the blockchain to when it cannot be edited; Before the transaction type data is submitted, the balance status of the sender and the receiver is first checked according to the status database, and the temporary balance that meets the conditions is updated to the fixed balance. The condition must meet the submission time of the transaction corresponding to the temporary balance plus the time period Δt is greater than or equal to the submission time of the current transaction; the sender can only use the fixed balance when transferring money, and the receiver must put the balance into the temporary balance set after the Δt time period after accepting the transfer; The time period Δt is dynamically adjusted according to the frequency of transactions in the actual application scenario; each element in the temporary balance set represents the balance accepted by the recipient for each transaction plus the timestamp corresponding to the transaction.

3. The submission method according to claim 1, characterized in that: In step S102, recording the time series attributes and updating the state database includes: After the transaction is packaged by the sorting node through consensus, all transactions in the block are traversed, and the storage location of each transaction in the blockchain is recorded, that is, the timing attribute corresponding to the transaction; the packaged block is sent to the submission node for verification, and the status of the corresponding KEY in the status database is updated according to the status and timing attributes corresponding to the transaction.

4. A blockchain transaction editing method based on the blockchain transaction submission method based on time series attributes according to any one of claims 1 to 3, characterized in that: Applied to blockchain client nodes, including the following steps: S201, receiving a transaction editing request sent by a client node, wherein the editing request at least includes: a KEY value of a target historical transaction edited by the client node, parameters of the target historical transaction, a timestamp, and edited transaction parameters; S202, based on the historical transaction parameters input by the client node, chain search is performed using the state data and the timing attributes of the previous transaction saved in the transaction as indexes; S203, using the timing attributes of the target historical transaction corresponding to the previous transaction and the modified transaction parameters as input to construct new transaction data and submit it; S204. Deserialize all historical transactions on the retrieval path when performing chain search with timing attributes, record the transaction metadata and enter the transaction pool. After the modified transaction is correctly submitted, submit the transaction in the transaction pool again in the timing order to maintain the correct timing relationship.

5. The editing method according to claim 4, characterized in that: In step S202, the state database is searched according to the KEY value sent by the client node to confirm whether the correct target KEY value and state exist: If the correct KEY value and status exist, search through the time series attributes in the status to find the target transaction metadata and reconstruct the transaction subtree; If the target KEY value does not exist or the target KEY value exists but the end bit in the corresponding status shows that the KEY value has been logically deleted, it is considered that the historical transaction corresponding to the KEY value has been deleted and cannot be edited, and failure is returned.

6. A blockchain transaction query method based on the blockchain transaction submission method based on time series attributes according to any one of claims 1 to 3, characterized in that: Applied to blockchain nodes, including the following steps: S301, receiving a query request sent by a client node, wherein the query request at least includes: querying a KEY value corresponding to a historical transaction; S302, searching the state database according to the KEY value corresponding to the historical transaction of the target query, and obtaining the position of the transaction corresponding to the latest state of the KEY value according to the latest state, that is, the time sequence attribute of the preceding transaction; S303. Obtain the corresponding block according to the timing attribute, deserialize the block and parse the transaction metadata according to the position of the transaction in the block, and then further query according to the timing attribute of the preceding transaction included in the transaction; S304. Record the historical snapshot of the KEY value contained in the transaction, that is, the historical status, according to the queried transaction metadata; until the time series attribute in the transaction is empty, return all historical records to the client node.

7. The query method according to claim 6, characterized in that: In step S302, the state database is searched according to the KEY value sent by the client node to confirm whether the correct target KEY value and state exist: If the correct KEY value and status exist, the corresponding transaction metadata is retrieved through the timing attributes in the status, and recursively retrieved through the timing attributes in the transaction; If the target KEY value does not exist or the target KEY value exists but the end bit in the corresponding status shows that the KEY value has been logically deleted, an empty set is directly returned to the client and the query ends.