CN110471923B - Processing method and device for blockchain transaction records - Google Patents

Processing method and device for blockchain transaction records Download PDF

Info

Publication number
CN110471923B
CN110471923B CN201910740313.3A CN201910740313A CN110471923B CN 110471923 B CN110471923 B CN 110471923B CN 201910740313 A CN201910740313 A CN 201910740313A CN 110471923 B CN110471923 B CN 110471923B
Authority
CN
China
Prior art keywords
transaction
state
block height
record
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910740313.3A
Other languages
Chinese (zh)
Other versions
CN110471923A (en
Inventor
张开翔
莫楠
范瑞彬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN201910740313.3A priority Critical patent/CN110471923B/en
Publication of CN110471923A publication Critical patent/CN110471923A/en
Priority to PCT/CN2020/104621 priority patent/WO2021027531A1/en
Application granted granted Critical
Publication of CN110471923B publication Critical patent/CN110471923B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/389Keeping log of transactions for guaranteeing non-repudiation of a transaction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • General Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Finance (AREA)
  • General Business, Economics & Management (AREA)
  • Strategic Management (AREA)
  • Economics (AREA)
  • Development Economics (AREA)
  • Marketing (AREA)
  • Computational Linguistics (AREA)
  • Technology Law (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

The invention discloses a processing method and a device for a blockchain transaction record, wherein the method comprises the following steps: after the blockchain system confirms that the first transaction is effective, determining a first state table corresponding to the first transaction; updating a first state result obtained according to the first transaction to a first state record in a first state table; after the first state table is determined to have the corresponding first history modification record table, first modification information corresponding to the first transaction is newly added in the first history modification record table, and the first modification information comprises a first state result. The technical scheme is used for storing the history modification record and realizing quick inquiry when inquiring the data on the appointed block.

Description

Processing method and device for blockchain transaction records
Technical Field
The embodiment of the invention relates to the field of financial science and technology (Fintech), in particular to a processing method and a processing device of a blockchain transaction record.
Background
With the development of computer technology, more and more technologies are applied in the financial field, the traditional financial industry is gradually changed to the financial technology, and the BlockChain technology (BlockChain) is not exceptional, but the higher requirements on the BlockChain technology are also put forward due to the requirements on the safety and the real-time performance of the financial and payment industries.
In existing blockchain systems supporting "state models," when a state data is modified, it changes from an old value to a new value, and in this process, including the value before modification and the new value after modification, a "modification record" is generated, and when this data is modified multiple times, a series of past modification records become "history modification records". In the prior art, the history modification record is not saved, and only the latest value of the data is reserved, namely the new modified value directly covers the old value.
However, the method of not storing the historical data has the defects that if the transaction at a certain block height needs to be traced back to cause the modification of certain data, the transaction cannot be directly inquired, and all the transactions need to be replayed to be inquired.
Disclosure of Invention
The embodiment of the invention provides a processing method and a processing device for a blockchain transaction record, which are used for storing a history modification record and realizing quick inquiry when inquiring data on a designated block.
A method of processing a blockchain transaction record for a blockchain system, the method comprising:
after the blockchain system confirms that the first transaction is effective, determining a first state table corresponding to the first transaction; the first state table is only used for recording the latest state result of each transaction account;
Updating a first state result obtained according to the first transaction to a first state record in the first state table; the first state record is used for recording the latest state result of a first transaction account corresponding to the first transaction;
after the first state table is determined to have a corresponding first history modification record table, first modification information corresponding to the first transaction is newly added in the first history modification record table, and the first modification information comprises the first state result.
In the technical scheme, the state table and the history modification record table are arranged on the blockchain system of the storage engine supporting the table structure, the history modification record table is used for storing the history modification record of the transaction account, and the state table and the history modification record table are independently stored, so that the storage and maintenance are facilitated. After the first transaction is effective, the state table and the history modification record table can be updated respectively according to the first transaction, and after a query request is received, the state result on the height of a designated block is queried from the history modification record table.
Optionally, before the determining the first state table corresponding to the first transaction, the method further includes:
creating a state table and a history modification record table corresponding to each transaction type through intelligent contracts corresponding to each transaction type;
the determining the first state table corresponding to the first transaction includes:
and determining the first state table according to the transaction type of the first transaction.
In the technical scheme, the state table and the history modification record table corresponding to each transaction type are created through the intelligent contracts corresponding to each transaction type, which is equivalent to separating the state tables corresponding to different transaction types and separating the history modification record tables corresponding to different transaction types through the intelligent contracts corresponding to the transaction types, so that the state tables and the history modification record tables corresponding to different transaction types are managed.
Optionally, the first status record includes the first transaction account and a current block height, where the current block height is used to indicate a block height of a block corresponding to the first transaction;
the first modification information further includes the first transaction account, the current block height, and a historical block height; the history block height is used for indicating the block height of a block corresponding to a last transaction of the first transaction account.
According to the technical scheme, the current block height is set in the state record, the current block height and the history block height are set in the modification information, the state table and the history modification record table can be combined, and meanwhile, the history modification record table is set to be of a group structure or a chain structure according to the current block height and the history block height of each modification information in the history modification record table, so that a corresponding state result can be conveniently queried according to the designated height in the query instruction.
Optionally, the first state record further includes a first hash key value; the first hash key value is determined according to the table name of the first state table and the first transaction account;
the first modification information further comprises a second hash key value; the second hash key is determined based on a table name of the first history modification record table, the first transaction account, and the current block height.
According to the technical scheme, the global uniqueness can be guaranteed through the hash value, and the data to be queried can be rapidly indexed.
Optionally, the method further comprises:
receiving a transaction inquiry instruction, wherein the transaction inquiry instruction is used for acquiring a state result of a second transaction account when a specified block height is reached;
Determining a second state table corresponding to the transaction inquiry instruction according to the transaction type in the transaction inquiry instruction;
determining the current block height in a second state record corresponding to the second transaction account in the second state table;
and when the specified block height is smaller than the current block height in the second state record, determining a state result corresponding to the transaction inquiry instruction from a second history modification record table corresponding to the second state table.
In the above technical solution, after receiving the transaction inquiry command, the current block height may be determined from the second state table corresponding to the transaction inquiry command, and if it is determined that the specified block height is smaller than the current block height, then determining that the state result corresponding to the transaction inquiry command is determined from the second history modification record table corresponding to the second state table.
Optionally, the determining, from the second history modification record table corresponding to the second state table, the state result corresponding to the transaction inquiry instruction includes:
determining second modification information corresponding to the second transaction account in the second history modification record table; the current block height in the second modification information is the nearest block height in the current block heights of the modification information in the second transaction account; the nearest specified block height means that the block height is not greater than the maximum block height value of the specified block height;
And determining a second state result in the second modification information as a state result corresponding to the transaction inquiry instruction.
In the above technical solution, the second history modification record table determines second modification information corresponding to the second transaction account, where the current block height of the second modification information corresponds to the same status result as the specified block height, that is, a modification record is recorded in the current block height of the second modification information, and no new modification record is recorded in the current block height of the second modification information until the specified block height, and the status result corresponding to the specified block height can be determined by determining the second modification information.
Optionally, the determining the second modification information corresponding to the second transaction account in the second history modification record table includes:
and querying the second history modification record table through an index dichotomy, a traversal method or a jump table method, and determining second modification information corresponding to the second transaction account.
In the above technical solution, the second modification information may be determined from the second history modification record table in various manners.
Optionally, the method further comprises:
when the specified block height is not smaller than the current block height in the second state records, determining a second state record corresponding to the second transaction account from the second state table;
And determining a third state result in the second state record as a state result corresponding to the transaction inquiry instruction.
In the above technical solution, after receiving the transaction inquiry command, the current block height may be determined from the second state table corresponding to the transaction inquiry command, and if it is determined that the specified block height is not less than the current block height, it may be indicated that the state result of the transaction account is not modified between the current block height and the specified block height, that is, the third state result in the second state record is the state result corresponding to the transaction inquiry command.
Correspondingly, the embodiment of the invention also provides a processing device of the blockchain transaction record, which is suitable for a blockchain system and comprises the following components:
the processing unit is used for determining a first state table corresponding to the first transaction after the blockchain system confirms that the first transaction is effective; the first state table is only used for recording the latest state result of each transaction account;
the updating unit is used for updating a first state result obtained according to the first transaction to a first state record in the first state table; the first state record is used for recording the latest state result of a first transaction account corresponding to the first transaction;
The updating unit is further configured to, after determining that the first state table has a corresponding first history modification record table, add first modification information corresponding to the first transaction in the first history modification record table, where the first modification information includes the first state result.
Optionally, the processing unit is further configured to:
before the first state table corresponding to the first transaction is determined, a state table and a history modification record table corresponding to each transaction type are created through intelligent contracts corresponding to each transaction type;
the processing unit is specifically configured to:
and determining the first state table according to the transaction type of the first transaction.
Optionally, the first status record includes the first transaction account and a current block height, where the current block height is used to indicate a block height of a block corresponding to the first transaction;
the first modification information further includes the first transaction account, the current block height, and a historical block height; the history block height is used for indicating the block height of a block corresponding to a last transaction of the first transaction account.
Optionally, the first state record further includes a first hash key value; the first hash key value is determined according to the table name of the first state table and the first transaction account;
The first modification information further comprises a second hash key value; the second hash key is determined based on a table name of the first history modification record table, the first transaction account, and the current block height.
Optionally, the processing unit is further configured to:
receiving a transaction inquiry instruction, wherein the transaction inquiry instruction is used for acquiring a state result of a second transaction account when a specified block height is reached;
determining a second state table corresponding to the transaction inquiry instruction according to the transaction type in the transaction inquiry instruction;
determining the current block height in a second state record corresponding to the second transaction account in the second state table;
and when the specified block height is smaller than the current block height in the second state record, determining a state result corresponding to the transaction inquiry instruction from a second history modification record table corresponding to the second state table.
Optionally, the processing unit is specifically configured to:
determining second modification information corresponding to the second transaction account in the second history modification record table; the current block height in the second modification information is the nearest block height in the current block heights of the modification information in the second transaction account; the nearest specified block height means that the block height is not greater than the maximum block height value of the specified block height;
And determining a second state result in the second modification information as a state result corresponding to the transaction inquiry instruction.
Optionally, the processing unit is specifically configured to:
and querying the second history modification record table through an index dichotomy, a traversal method or a jump table method, and determining second modification information corresponding to the second transaction account.
Optionally, the processing unit is further configured to:
when the specified block height is not smaller than the current block height in the second state records, determining a second state record corresponding to the second transaction account from the second state table;
and determining a third state result in the second state record as a state result corresponding to the transaction inquiry instruction.
Accordingly, an embodiment of the present invention further provides a computing device, including:
a memory for storing program instructions;
and the processor is used for calling the program instructions stored in the memory and executing the processing method of the blockchain transaction record according to the obtained program.
Correspondingly, the embodiment of the invention also provides a computer readable nonvolatile storage medium, which comprises computer readable instructions, and when the computer reads and executes the computer readable instructions, the computer is caused to execute the processing method of the blockchain transaction record.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart illustrating a method for processing a blockchain transaction record according to an embodiment of the present invention;
fig. 2 is a flow chart of a query method for transaction records according to an embodiment of the present invention;
FIG. 3 is a first history modification table structure according to an embodiment of the present invention;
FIG. 4 is a second history modification table structure according to an embodiment of the present invention;
FIG. 5 is a third history modification table structure according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a processing device for blockchain transaction records according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail below with reference to the accompanying drawings, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The processing method of the blockchain transaction record is applicable to a blockchain system, wherein the blockchain system is a P2P (Peer to Peer) network consisting of a plurality of blockchain nodes, and the blockchain nodes can be mutually and directly communicated. Data generated by one blockchain node can be simultaneously transmitted to a plurality of blockchain links for broadcasting, and can also be inquired and acquired from other arbitrary nodes.
There is a state table in the blockchain system created by the smart contracts of the same transaction type as it, the state table being used to record the latest state results for each transaction account of that transaction type. The status results of a certain transaction account may be kept in the form of status records, i.e. status records are used to record the latest status results of the transaction account. Alternatively, the state results may be generated by the smart contract, corresponding to a state table used to hold the "current value" of the state results generated by the smart contract on the blockchain.
The state table may include the results of each transaction account and the corresponding latest state for each transaction account in the blockchain system. If the first state table is a Balance table, the state table includes the latest Balance value of each transaction account, the table Name of the state table may be a Balance table (t_balance), and the table field includes the transaction account (Name) and the Balance value (Balance).
The table field of the state table may also include a hash Key (Key) and a current block height (Blocknum).
The hash key value is understood as an index value in a state table and is used for indexing a state result corresponding to the transaction account, optionally, the hash key value may be determined according to a table name of the state table and the transaction account, and an exemplary manner of generating the hash key value may be SHA256 (table name + minus + primary key) so as to ensure global uniqueness. If a transaction account is used as a primary Key, and the name of a transaction account is "Alice" in the Balance table, key=sha256 ("t_balance-Alice").
The current block height is used for indicating that the transaction corresponding to the state result is packed to the block height of the block, and it is understood that after the transaction of the block chain is confirmed, the transaction is packed to the block and is uplink, the intelligent contract modifies the state result of the transaction account according to the transaction and writes the modified state result into the corresponding state table, wherein the block height (namely, the current block height of the block chain) where the block is located when the block is uplink is written into the corresponding state table together.
The invention provides a state table for representing Balance, the table name of the state table is t_balance, and the table field comprises Key, blocknum, name, balance, as shown in table 1. The state table comprises state records corresponding to the transaction accounts, and each state record is used for recording the latest state result of the corresponding transaction account.
TABLE 1
It should be noted that, the status table may be a balance table, or may be a table corresponding to other transaction types, such as a member table (t_member), an order table (t_order), etc.
In the embodiment of the invention, when the state table is created, the history modification record table corresponding to the state table can be created at the same time, which is equivalent to that the state table and the history modification record table corresponding to each transaction type can be created by the intelligent contract corresponding to each transaction type. The state table is used for recording the latest state result of a certain transaction account, the history modification record table is used for recording all history state results of the transaction account, only one state record is recorded for one transaction account in the state table, and N pieces of modification information are provided for N times of modification for one transaction account in the history modification record table, wherein N is greater than or equal to 1.
When executing the create status table, the incoming create instruction includes whether to generate a history modification record table. For historical data that is not of interest, the history modification record table may not be generated to reduce storage overhead. If the generation history modification record table is specified, two tables are actually generated in the underlying storage.
In the blockchain database, a record of creating a state table may be recorded, which is used for characterizing whether the history modification record table corresponding to the state table is created, or the record of creating may be stored in a table form, as shown in table 2, and may include the table name of the state table and whether the history modification record table is generated.
TABLE 2
Table name of state table Whether to generate a history modification record table
t_Balance True
t_member True
t_order False
The table name of the history modification record table may be the table name of the corresponding state table added with the suffix "_history", and the history modification record table may have one more field than the state table, that is, the block height (prevblock num) of the last history value, for recording the block height of the last changed state result, that is, the current block height of the last modified state result, and may be related to the last history data by the block height of the last history value. The hash Key value in the history modification record table may be determined according to the table name and transaction account of the history modification record table, and the current block height, and for example, the hash Key value in the history modification record table may be generated by SHA256 (table name+primary key+current block height), if the transaction account is taken as the primary Key, and the name of one transaction account in the Balance table is "Alice", then key=sha256 ("t_balance_history-Alice-2").
In combination with table 1, the present invention provides a history modification record table for characterizing Balance, where the table name of the history modification record table is t_balance_history, the table field includes Key, blocknum, name, balance, prevblocknum, and as Alice in table 3 is an example, alice's history modification record table includes modification information of each time, and the modification information is used for recording the history state result of Alice. Where Prevblocknum is-1, indicating that this record was inserted when it was newly created. When modifying data, it is known that Alice's Balance is 100 at block height 2, no modification is made between blocks with block heights 3 to 9, and then another transaction modifies Alice's Balance to 200 at block height 10.
TABLE 3 Table 3
Based on the above description, fig. 1 illustrates a flow of a processing method of a blockchain transaction record according to an embodiment of the present invention, where the flow may be executed by a processing device of the blockchain transaction record.
As shown in fig. 1, the process specifically includes:
step 101, after the blockchain system confirms that the first transaction is effective, determining a first state table corresponding to the first transaction;
step 102, updating a first state result obtained according to the first transaction to a first state record in a first state table;
step 103, after determining that the first state table has a corresponding first history modification record table, adding first modification information corresponding to the first transaction in the first history modification record table.
The first state table is used for recording the latest state result of each transaction account, and is the state table of the same transaction type as the first transaction, and the first state table comprises the state records corresponding to each transaction account. The first state record of the first transaction account corresponding to the first transaction in the first state table can be updated according to the first transaction, and the first state record is used for recording the latest state result of the first transaction account.
After the first state result obtained according to the first transaction, the first state result may be updated to the first state record in the first state table, and meanwhile, the first state result is recorded in the first modification information and then added to the first history modification record table.
In the embodiment of the present invention, there is a first history modification record table corresponding to the first state table, that is, before step 101, a first history record table of the same transaction type as the first state table is created by an intelligent contract corresponding to the first state table. In step 101, a transaction type corresponding to the first transaction exchange may be determined, and a first state table corresponding to the transaction type may be determined according to the transaction type.
When the first state record is updated into the first state table, the current block height corresponding to the first transaction and the first transaction account may be recorded together in the first state record, where the current block height refers to the block height of the block corresponding to the first transaction. When the first modification information is added to the first history modification record table, the current block height, the first transaction account and the history block height corresponding to the last modification can be recorded together in the first modification information, wherein the history block height is the block height of the block corresponding to the last transaction before the first transaction of the first transaction account.
Optionally, the first state record further includes a first hash key value, where the first hash key value is determined according to a table name of the first state table and the first transaction account; the first modification information further comprises a second hash key value; the second hash key is determined based on the table name of the first history modification table, the first transaction account, and the current block height.
For example, in connection with table 3, alice's current balance is 400 and recorded on a block with a block height of 21, and in this state table, alice's current balance is 400 and the corresponding block height is 21, the state record may be as shown in table 4 (a). If the current block height of the blockchain is 30, a transaction for changing the balance of Alice is received, and the transaction indicates that the balance of Alice becomes 500, the current balance of Alice becomes 500 in the state table, and the corresponding block height is 30, which can be shown in table 4 (b); the new piece of modification information is shown in table 3, and the new piece of modification information can be shown in table 4 (c), wherein. A Prevblocknum of 21 means that the last modification was at a block height of 21.
Table 4 (a)
Table 4 (b)
Table 4 (c)
The above embodiments describe the processing method of the blockchain transaction record in detail, specifically, update the status record of the transaction account into the status table, and add the modification information of the transaction account into the history modification record table. The embodiment of the invention also provides a transaction record inquiring method based on the state table and the history modification record table.
The flow chart may be as shown in fig. 2.
Step 201, receiving a transaction inquiry instruction;
step 202, determining a second state table corresponding to the transaction inquiry instruction according to the transaction type in the transaction inquiry instruction;
step 203, determining the current block height in a second state record corresponding to the second transaction account in the second state table;
and 204, determining a state result corresponding to the transaction inquiry instruction from a second history modification record table corresponding to the second state table when the specified block height is smaller than the current block height in the second state record.
The transaction inquiry command includes a designated block height to be inquired and a transaction account, if the transaction inquiry command is "Alice 15", the transaction inquiry command represents a status result of inquiring Alice when the block height is 15. That is, the transaction inquiry instruction is used to obtain the status result of the second transaction account at the specified block height.
The current block height of the second state record in the second state table may be determined first and compared to the size of the specified block height. The following two cases are adopted:
case one: determining second modification information corresponding to a second transaction account in a second history modification record table if the specified block height is smaller than the current block height in the second state record, and determining a second state result in the second modification information as a state result corresponding to the transaction inquiry instruction;
And a second case: and if the specified block height is not smaller than the current block height in the second state record, determining a second state record corresponding to the second transaction account from the second state table, and determining a third state result in the second state record as a state result corresponding to the transaction inquiry instruction.
In one aspect, the current block height of the second modification information is a closest specified block height among the current block heights of the modification information in the second transaction account, where the closest specified block height refers to a maximum block height value where the block height is not greater than the specified block height. Taking table 3 as an example, if the specified block height is 15, the modification information on the block height of 10 is determined to be the second modification information.
When determining the second modification information corresponding to the second transaction account in the second historical modification record table, an index dichotomy, a traversal method or a jump table method can be adopted to query the second historical modification record table, so as to determine the second modification information corresponding to the second transaction account. The index dichotomy, the traversal method, or the jump table method, respectively, is described below for querying the second history modification record table.
Index dichotomy (one)
When the history modification record table is stored using a database table of the RDBMS, or the storage medium supports random retrieval by subscript, a binary data query method may be used for querying the blockchain history, which may reduce the expected number of traversals of the query from n to log (n).
The history modification record table supporting random search is stored, each record has an Index (hereinafter referred to as a subscript) attribute, the subscript attribute is unique and self-increased, the history modification record table supports random search of data of any subscript, the current maximum subscript can be searched, and the structure of the history modification record table can be shown as a figure 3. Based on the history modification record table structure as in fig. 3, a binary search of history data can be performed.
Taking the example of querying Alice's balance. The state table is shown in table 5 (a), and the history table is shown in table 5 (b). Inquiring the balance current value of Alice, adopting Alice as Key, and directly inquiring the state table to obtain the current value; if the history modification record table is not established, the history modification record cannot be queried; if a history modification table is created, the history of Alice at a specified block height can be queried from the history modification table.
Table 5 (a)
Table 5 (b)
And modifying the structure of the record table according to the history, and adopting a binary search method. Firstly, a state table is queried to obtain the latest subscript of the Alice balance record and the block height, wherein the subscript is 4 in the example, and the block height is 21; if the input designated height is greater than the latest modified height, immediately returning to the current value in the state table; if the query height is less than the latest modification height, e.g. 15, this means that a modification value is to be found where the block height is less than 15.
The method comprises the following specific steps:
step 301, starting to query from the middle position of the history modification record table, i.e. query the record at the current index/2 (rounded), here query 4/2=2, i.e. the record with index 2;
step 302, if the block height value of the queried record is less than or equal to the target value (designated height) of the query, starting the query at the middle position of the range from the subscript 2 to the subscript 4, and if the block height of the queried record is greater than the target value of the query, starting the query at the middle position of the range from the subscript 0 to the subscript 2;
step 302, in this example, query the blocknum=10 of the record with subscript 2, which is smaller than the target value 15, and query the whole record at 2+2/2, i.e. the record with subscript 3, in the range from subscript 2 to subscript 4;
step 303, inquiring that blocknum=16 of the record with the subscript of 3 is greater than the target value of 15, and selecting the record with the maximum blocknum=10 of less than 15, namely the record with the subscript of 2, according to the history inquiry rule;
step 304, after the query is completed, the state record is queried as blocknum=10, and balance=200.
(two) traversal method
The traversal method starts from the latest record of the history modification record table, and sequentially acquires the PrevBlocknum of the record until the record is smaller than the specified height. The structure of the history modification table may be as shown in fig. 4.
Taking the example of querying Alice's balance. The state table is shown in table 6 (a), and the history table is shown in table 6 (b). Inquiring the balance current value of Alice, adopting Alice as Key, and directly inquiring the state table to obtain the current value; if the history modification record table is not established, the history modification record cannot be queried; if a history modification table is created, the history of Alice at a specified block height can be queried from the history modification table.
Table 6 (a)
Table 6 (b)
And modifying the structure of the record table according to the history, and adopting a traversal method. Firstly, inquiring a state table to obtain the latest block height of the record of Alice balance, wherein the block height is 21 in the example; if the input designated height is greater than the latest modified height, immediately returning to the current value in the state table; if the query height is less than the latest modification height, e.g. 15, this means that a modification value is to be found where the block height is less than 15.
The method comprises the following specific steps:
step 401, calculate key=sha256 ("t_balance_history-Alice-21"), query the history modification record table; obtain balance=400, prevblocknum=16; wherein prevblocknum=16 is greater than the specified height 15;
step 402, calculate key=sha256 ("t_balance_history-Alice-16"), query the history modification record table; obtain balance=300, prevblocknum=10; wherein prevblocknum=10 is less than the specified height 15;
Step 403, calculate key=sha256 ("t_balance_history-Alice-10"), query the history modification record table; obtain balance=200, prevblocknum=2;
since the tile height 10 is the first record to be less than height 15, then a balance=200 can be returned.
The complexity of the traversal method depends on the number of times a record of a transaction account is modified, for example, alice's history modification record is irrelevant to Bob, because transaction accounts are different primary keys, and Key of the history modification record table considers the transaction account as the primary Key, and the history modification records of two persons are in the same table, but do not interfere with each other when querying.
(III) jump method
When the storage does not support random search and only supports key value inquiry, a group of jump tables can be added on the basis of traversing the inquiry method so as to improve the inquiry speed. In the data structure related to the traversal query method, an index table is added, and the index table can configure rules, such as adding an index record for every two records, as shown in fig. 5. When the history record is created, index records of the skip list are simultaneously generated, and each two history records are added according to the rule, and one skip list record is added.
Taking the example of querying Alice's balance. The state table is shown in table 7 (a), the history table is shown in table 7 (b), and the jump table is shown in table 7 (c). Inquiring the balance current value of Alice, adopting Alice as Key, and directly inquiring the state table to obtain the current value; if the history modification record table is not established, the history modification record cannot be queried; if a history modification table is created, the history of Alice at a specified block height can be queried from the history modification table.
Table 7 (a)
Table 7 (b)
Table 7 (c)
/>
And modifying the structure of the record table according to the history, and adopting a jump table method. Firstly, inquiring a state table to obtain the latest block height of the record of Alice balance, wherein the block height is 21 in the example; if the input designated height is greater than the latest modified height, immediately returning to the current value in the state table; if the query height is less than the latest modification height, e.g. 15, this means that a modification value is to be found where the block height is less than 15.
The method comprises the following specific steps:
step 501, starting to inquire from the starting position of the jump table, wherein the inquired blocknum=21 is larger than the designated height 15;
step 502, inquiring the next hop of the hop table, wherein the inquired blocknum=10 is smaller than the designated height 15;
step 503, confirming that the specified height 15 is between the blocknum=10 and the blocknum=21, traversing from the history of blocknum=21, and querying the record of blocknum=10;
in step 504, the record blocknum=10 and balance=200 is queried.
The jump table inquiry method can halve the expected traversal number of inquiry, reduce n to n/2, if higher inquiry efficiency is needed, introduce multi-stage jump table, and superimpose the jump table on the current jump table, finally reduce traversal times from n to log (n).
In the above embodiment, the state table and the history modification record table are set on the blockchain system of the storage engine supporting the table structure, and the history modification record table is used for storing the history modification record of the transaction account, and the state table and the history modification record table are independently stored, so that the storage and maintenance are facilitated. After the first transaction is effective, the state table and the history modification record table can be updated respectively according to the first transaction, and after a query request is received, the state result on the height of a designated block is queried from the history modification record table.
Based on the same inventive concept, fig. 6 illustrates an exemplary structure of a blockchain transaction record processing device according to an embodiment of the present invention, where the device may execute a flow of a blockchain transaction record processing method.
The apparatus, adapted for use in a blockchain system, includes:
a processing unit 601, configured to determine a first state table corresponding to a first transaction after the blockchain system confirms that the first transaction is effective; the first state table is only used for recording the latest state result of each transaction account;
An updating unit 602, configured to update a first status result obtained according to the first transaction to a first status record in the first status table; the first state record is used for recording the latest state result of a first transaction account corresponding to the first transaction;
the updating unit 602 is further configured to, after determining that the first state table has a corresponding first history modification record table, add first modification information corresponding to the first transaction in the first history modification record table, where the first modification information includes the first state result.
Optionally, the processing unit 601 is further configured to:
before the first state table corresponding to the first transaction is determined, a state table and a history modification record table corresponding to each transaction type are created through intelligent contracts corresponding to each transaction type;
the processing unit 601 is specifically configured to:
and determining the first state table according to the transaction type of the first transaction.
Optionally, the first status record includes the first transaction account and a current block height, where the current block height is used to indicate a block height of a block corresponding to the first transaction;
the first modification information further includes the first transaction account, the current block height, and a historical block height; the history block height is used for indicating the block height of a block corresponding to a last transaction of the first transaction account.
Optionally, the first state record further includes a first hash key value; the first hash key value is determined according to the table name of the first state table and the first transaction account;
the first modification information further comprises a second hash key value; the second hash key is determined based on a table name of the first history modification record table, the first transaction account, and the current block height.
Optionally, the processing unit 601 is further configured to:
receiving a transaction inquiry instruction, wherein the transaction inquiry instruction is used for acquiring a state result of a second transaction account when a specified block height is reached;
determining a second state table corresponding to the transaction inquiry instruction according to the transaction type in the transaction inquiry instruction;
determining the current block height in a second state record corresponding to the second transaction account in the second state table;
and when the specified block height is smaller than the current block height in the second state record, determining a state result corresponding to the transaction inquiry instruction from a second history modification record table corresponding to the second state table.
Optionally, the processing unit 601 is specifically configured to:
determining second modification information corresponding to the second transaction account in the second history modification record table; the current block height in the second modification information is the nearest block height in the current block heights of the modification information in the second transaction account; the nearest specified block height means that the block height is not greater than the maximum block height value of the specified block height;
And determining a second state result in the second modification information as a state result corresponding to the transaction inquiry instruction.
Optionally, the processing unit 601 is specifically configured to:
and querying the second history modification record table through an index dichotomy, a traversal method or a jump table method, and determining second modification information corresponding to the second transaction account.
Optionally, the processing unit 601 is further configured to:
when the specified block height is not smaller than the current block height in the second state records, determining a second state record corresponding to the second transaction account from the second state table;
and determining a third state result in the second state record as a state result corresponding to the transaction inquiry instruction.
Based on the same inventive concept, an embodiment of the present invention further provides a computing device, including:
a memory for storing program instructions;
and the processor is used for calling the program instructions stored in the memory and executing the processing method of the blockchain transaction record according to the obtained program.
Based on the same inventive concept, the embodiment of the invention also provides a computer readable nonvolatile storage medium, which comprises computer readable instructions, when the computer reads and executes the computer readable instructions, the computer is caused to execute the processing method of the blockchain transaction record.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made to the present invention without departing from the spirit or scope of the invention. Thus, it is intended that the present invention also include such modifications and alterations insofar as they come within the scope of the appended claims or the equivalents thereof.

Claims (16)

1. A method of processing a blockchain transaction record, the method comprising:
After the blockchain system confirms that the first transaction is effective, determining a first state table corresponding to the first transaction; the first state table is only used for recording the latest state result of each transaction account;
updating a first state result obtained according to the first transaction to a first state record in the first state table; the first state record is used for recording the latest state result of a first transaction account corresponding to the first transaction;
after the first state table is determined to have a corresponding first history modification record table, first modification information corresponding to the first transaction is newly added in the first history modification record table, and the first modification information comprises the first state result;
the first state record comprises the first transaction account and a current block height, wherein the current block height is used for indicating the block height of a block corresponding to the first transaction;
the first modification information further includes the first transaction account, the current block height, and a historical block height; the history block height is used for indicating the block height of a block corresponding to a last transaction of the first transaction account.
2. The method of claim 1, further comprising, prior to said determining a first state table corresponding to said first transaction:
Creating a state table and a history modification record table corresponding to each transaction type through intelligent contracts corresponding to each transaction type;
the determining the first state table corresponding to the first transaction includes:
and determining the first state table according to the transaction type of the first transaction.
3. The method of claim 1, wherein the first state record further comprises a first hash key; the first hash key value is determined according to the table name of the first state table and the first transaction account;
the first modification information further comprises a second hash key value; the second hash key is determined based on a table name of the first history modification record table, the first transaction account, and the current block height.
4. The method of claim 1, wherein the method further comprises:
receiving a transaction inquiry instruction, wherein the transaction inquiry instruction is used for acquiring a state result of a second transaction account when a specified block height is reached;
determining a second state table corresponding to the transaction inquiry instruction according to the transaction type in the transaction inquiry instruction;
determining the current block height in a second state record corresponding to the second transaction account in the second state table;
And when the specified block height is smaller than the current block height in the second state record, determining a state result corresponding to the transaction inquiry instruction from a second history modification record table corresponding to the second state table.
5. The method of claim 4, wherein determining the status result corresponding to the transaction query instruction from the second history modification record table corresponding to the second status table comprises:
determining second modification information corresponding to the second transaction account in the second history modification record table; the current block height in the second modification information is the nearest block height in the current block heights of the modification information in the second transaction account; the nearest specified block height means that the block height is not greater than the maximum block height value of the specified block height;
and determining a second state result in the second modification information as a state result corresponding to the transaction inquiry instruction.
6. The method of claim 5, wherein the determining second modification information corresponding to the second transaction account in the second history modification record table comprises:
and querying the second history modification record table through an index dichotomy, a traversal method or a jump table method, and determining second modification information corresponding to the second transaction account.
7. The method as recited in claim 4, further comprising:
when the specified block height is not smaller than the current block height in the second state records, determining a second state record corresponding to the second transaction account from the second state table;
and determining a third state result in the second state record as a state result corresponding to the transaction inquiry instruction.
8. A processing apparatus for blockchain transaction records, the apparatus comprising:
the processing unit is used for determining a first state table corresponding to the first transaction after the blockchain system confirms that the first transaction is effective; the first state table is only used for recording the latest state result of each transaction account;
the updating unit is used for updating a first state result obtained according to the first transaction to a first state record in the first state table; the first state record is used for recording the latest state result of a first transaction account corresponding to the first transaction;
the updating unit is further configured to, after determining that the first state table has a corresponding first history modification record table, add first modification information corresponding to the first transaction in the first history modification record table, where the first modification information includes the first state result; the first state record comprises the first transaction account and a current block height, wherein the current block height is used for indicating the block height of a block corresponding to the first transaction;
The first modification information further includes the first transaction account, the current block height, and a historical block height; the history block height is used for indicating the block height of a block corresponding to a last transaction of the first transaction account.
9. The apparatus of claim 8, wherein the processing unit is further to:
before the first state table corresponding to the first transaction is determined, a state table and a history modification record table corresponding to each transaction type are created through intelligent contracts corresponding to each transaction type;
the processing unit is specifically configured to:
and determining the first state table according to the transaction type of the first transaction.
10. The apparatus of claim 9, wherein the first state record further comprises a first hash key; the first hash key value is determined according to the table name of the first state table and the first transaction account;
the first modification information further comprises a second hash key value; the second hash key is determined based on a table name of the first history modification record table, the first transaction account, and the current block height.
11. The apparatus of claim 9, wherein the processing unit is further to:
Receiving a transaction inquiry instruction, wherein the transaction inquiry instruction is used for acquiring a state result of a second transaction account when a specified block height is reached;
determining a second state table corresponding to the transaction inquiry instruction according to the transaction type in the transaction inquiry instruction;
determining the current block height in a second state record corresponding to the second transaction account in the second state table;
and when the specified block height is smaller than the current block height in the second state record, determining a state result corresponding to the transaction inquiry instruction from a second history modification record table corresponding to the second state table.
12. The apparatus of claim 11, wherein the processing unit is specifically configured to:
determining second modification information corresponding to the second transaction account in the second history modification record table; the current block height in the second modification information is the nearest block height in the current block heights of the modification information in the second transaction account; the nearest specified block height means that the block height is not greater than the maximum block height value of the specified block height;
and determining a second state result in the second modification information as a state result corresponding to the transaction inquiry instruction.
13. The apparatus of claim 12, wherein the processing unit is specifically configured to:
and querying the second history modification record table through an index dichotomy, a traversal method or a jump table method, and determining second modification information corresponding to the second transaction account.
14. The apparatus of claim 12, wherein the processing unit is further to:
when the specified block height is not smaller than the current block height in the second state records, determining a second state record corresponding to the second transaction account from the second state table;
and determining a third state result in the second state record as a state result corresponding to the transaction inquiry instruction.
15. A computing device, comprising:
a memory for storing program instructions;
a processor for invoking program instructions stored in said memory to perform the method of any of claims 1-7 in accordance with the obtained program.
16. A computer readable non-transitory storage medium comprising computer readable instructions which, when read and executed by a computer, cause the computer to perform the method of any of claims 1 to 7.
CN201910740313.3A 2019-08-12 2019-08-12 Processing method and device for blockchain transaction records Active CN110471923B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910740313.3A CN110471923B (en) 2019-08-12 2019-08-12 Processing method and device for blockchain transaction records
PCT/CN2020/104621 WO2021027531A1 (en) 2019-08-12 2020-07-24 Block chain transaction record processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910740313.3A CN110471923B (en) 2019-08-12 2019-08-12 Processing method and device for blockchain transaction records

Publications (2)

Publication Number Publication Date
CN110471923A CN110471923A (en) 2019-11-19
CN110471923B true CN110471923B (en) 2024-01-16

Family

ID=68511440

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910740313.3A Active CN110471923B (en) 2019-08-12 2019-08-12 Processing method and device for blockchain transaction records

Country Status (2)

Country Link
CN (1) CN110471923B (en)
WO (1) WO2021027531A1 (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110471923B (en) * 2019-08-12 2024-01-16 深圳前海微众银行股份有限公司 Processing method and device for blockchain transaction records
CN111161064A (en) * 2019-12-12 2020-05-15 深圳前海微众银行股份有限公司 Processing method and device for blockchain transaction records
CN111415229A (en) * 2020-04-21 2020-07-14 昆明大棒客科技有限公司 Block chain based e-commerce transaction method, device and equipment
CN113256419B (en) * 2021-05-21 2022-09-02 上海简苏网络科技有限公司 Block chain transaction retrieval method and system
CN113468224A (en) * 2021-09-03 2021-10-01 支付宝(杭州)信息技术有限公司 Method and device for storing and inquiring state data and executing transaction in block chain
CN113505138B (en) * 2021-09-06 2021-12-21 支付宝(杭州)信息技术有限公司 Method and apparatus for state attestation and execution of blocks in a blockchain system
CN113961568A (en) * 2021-12-22 2022-01-21 南京金宁汇科技有限公司 Block chain-based block fast searching method for chain data structure

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108282474A (en) * 2018-01-18 2018-07-13 山东大学 The maintaining method of digital asset trade identity based on block chain
CN109063016A (en) * 2018-07-11 2018-12-21 物数(上海)信息科技有限公司 Block chain data storage method, device, electronic equipment, storage medium
CN110008233A (en) * 2019-03-31 2019-07-12 杭州复杂美科技有限公司 A kind of information inquiry and know together method, system, equipment and storage medium

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170140375A1 (en) * 2015-11-15 2017-05-18 Michael Kunstel System and Method for Permissioned Distributed Block Chain
CN106934619B (en) * 2017-03-13 2021-07-06 杭州复杂美科技有限公司 Transaction recording method and system
US10922692B2 (en) * 2017-04-05 2021-02-16 Samsung Sds Co., Ltd. Method for calculating confirmation reliability for blockchain based transaction and blockchain network monitoring system for performing the method
CN109447791B (en) * 2018-11-09 2021-07-16 北京邮电大学 Block chain-based fund transaction method and device
CN110096522B (en) * 2019-05-15 2023-07-28 西安电子科技大学 Block chain data processing method, device and equipment supporting relational retrieval
CN110471923B (en) * 2019-08-12 2024-01-16 深圳前海微众银行股份有限公司 Processing method and device for blockchain transaction records

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108282474A (en) * 2018-01-18 2018-07-13 山东大学 The maintaining method of digital asset trade identity based on block chain
CN109063016A (en) * 2018-07-11 2018-12-21 物数(上海)信息科技有限公司 Block chain data storage method, device, electronic equipment, storage medium
CN110008233A (en) * 2019-03-31 2019-07-12 杭州复杂美科技有限公司 A kind of information inquiry and know together method, system, equipment and storage medium

Also Published As

Publication number Publication date
CN110471923A (en) 2019-11-19
WO2021027531A1 (en) 2021-02-18

Similar Documents

Publication Publication Date Title
CN110471923B (en) Processing method and device for blockchain transaction records
CN110737664B (en) Method and device for synchronizing block chain link points
CN110602148B (en) Method and device for generating state tree of block and verifying data on chain
CN110020902B (en) Cross-link certificate storage method, access method, device and electronic equipment
CN104408159B (en) A kind of data correlation, loading, querying method and device
CN107710193A (en) The data of DCE place control
CN102799628A (en) Method and device for data partitioning in key-value database
CN111008521B (en) Method, device and computer storage medium for generating wide table
CN110597835B (en) Transaction data deleting method and device based on blockchain
CN109743346B (en) Session flow configuration method, device and computer-readable storage medium
CN106168963B (en) Real-time streaming data processing method and device and server
US11188535B2 (en) Distributed join operation processing method, apparatus, device, and storage medium
CN110704438B (en) Method and device for generating bloom filter in blockchain
CN110597852A (en) Data processing method, device, terminal and storage medium
CN110599166A (en) Method and device for acquiring transaction dependency relationship in block chain
CN106471501A (en) The method of data query, the storage method data system of data object
CN111723161A (en) Data processing method, device and equipment
CN110941741A (en) Path search processing method, device, server and storage medium for graph data
CN106815258A (en) A kind of date storage method and coordinator node
CN110597912B (en) Block storage method and device
CN105550220B (en) A kind of method and device of the access of heterogeneous system
CN111161064A (en) Processing method and device for blockchain transaction records
CN107291746A (en) A kind of method and apparatus for storing and reading data
CN110706108B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN116915791A (en) Block chain transaction conflict detection method, sequencing node and endorsement node

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant