WO2021068728A1 - Methods and apparatus for generating state tree of block and validating on-chain data - Google Patents

Methods and apparatus for generating state tree of block and validating on-chain data Download PDF

Info

Publication number
WO2021068728A1
WO2021068728A1 PCT/CN2020/116269 CN2020116269W WO2021068728A1 WO 2021068728 A1 WO2021068728 A1 WO 2021068728A1 CN 2020116269 W CN2020116269 W CN 2020116269W WO 2021068728 A1 WO2021068728 A1 WO 2021068728A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
account
data
account data
height
Prior art date
Application number
PCT/CN2020/116269
Other languages
French (fr)
Chinese (zh)
Inventor
陈宇
莫楠
李辉忠
张开翔
范瑞彬
Original Assignee
深圳前海微众银行股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2021068728A1 publication Critical patent/WO2021068728A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information
    • 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2209/00Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
    • H04L2209/56Financial cryptography, e.g. electronic payment or e-cash
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Definitions

  • the embodiments of the present invention relate to the field of financial technology (Fintech), and in particular to a method and device for generating a block state tree and verifying data on a chain.
  • the branch path of the contract state in the storage tree needs to be determined first to verify whether the contract state exists in the corresponding storage tree Then, the branch path of the account state corresponding to the storage tree in the state tree is determined, and then it is verified whether the account state exists in the corresponding state tree.
  • the embodiment of the present invention provides a method and device for generating the state tree of a block and verifying data on the chain, which is used to streamline the account data used to construct the state tree on the block chain, thereby shortening the length of the branch path for verification , Improve the efficiency of the existence verification of account data.
  • a method for generating a state tree of a block includes:
  • the first account is the account whose account data changes after the execution of each transaction in the block, the The first account data is the changed account data in the first account after the execution of each transaction; the state of the block composed of each first account and the first account data of each first account is constructed And store the root hash of the state tree in the block header of the block, wherein the state tree is stored in a key-value pair.
  • the constructing the state tree of the block composed of each first account and the first account data of each first account includes: any first account data for any first account, The identification of the first account, the identification of the first account data, and the block height of the block are used as the key value, and the first account data is used as the value value of the leaf node, and the block is constructed based on the MPT mode State tree.
  • the key value is directly stored persistently instead of the hash of the key value.
  • the account data under the same account has the same compression prefix, that is, the account ID or
  • the account address effectively uses the advantages of Patricia Tree to minimize the level of the state tree, reducing storage space and speeding up the construction and verification efficiency of branch paths.
  • the first account data includes a block height record, an account status, and/or a contract status that have changed in the first account after the execution of each transaction; the block height record is used to record the first The block height of the block where the account status and/or contract status in the account has been changed.
  • the account state originally belongs to the value in the leaf node of the state tree
  • the contract state originally belongs to the value in the leaf node of the storage tree.
  • the value in the leaf node of the state tree is moved down to the leaf node of the storage tree.
  • the value level in merges the state tree and the storage tree into one tree, thereby flattening the hierarchical structure of the account data, and speeding up the construction and verification efficiency of the branch path.
  • a key-value key-value pair is added when placing the disk for storage, where the key includes an account identifier and an account data identifier.
  • the account data identifier corresponds to the block height record
  • the value value is the block height record.
  • the high record is used to record the block height of the block where the account data in the account ID corresponds to the previous change. In this way, when verifying a certain account data, the block of the state tree where the account data is located can be determined first. Then determine the branch path for verification based on the block.
  • the method further includes: receiving a data acquisition request from the client; the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height; according to the identifier of the second account And the identifier of the first high record of the second account, determine the first high record; determine according to the identifier of the second account, the identifier of the second account data, and the first high record
  • the second account data; the first branch path used to verify the first block of high records is obtained from the state tree of the first block; the first block is the highest in the first block of high records The block corresponding to the block height; obtain the second branch path for verifying the second account data from the state tree of the second block; the second block is the block corresponding to the second block height; the The second block height is the highest block height of all block heights lower than the first block height in the first block height record; the first block height record, the first branch path, and the first block height are recorded. 2.
  • the account data and the second branch path are sent to the client
  • the blockchain node returns two sets of data to the client according to the client's data acquisition request.
  • the first set is the first high record and the first branch path used to verify the first high record
  • the second The group is the second account data and the second branch path used to verify the second account data, so the client can verify the first high record and the second account data respectively according to the two sets of data.
  • the first branch path and the second branch path are shorter than the branch paths in the prior art, the time required for the blockchain node to obtain the branch path is shorter, and the time required for client verification is also shorter. , Thereby improving the efficiency of the client to verify data.
  • an on-chain data verification method provided by an embodiment of the present invention includes:
  • the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height; receive the first block height record and the first block height returned by the blockchain node A branch path, second account data, and a second branch path; the first block of high records and the second account data are based on the identification of the second account and the second account data by the blockchain node And the first block height; the first branch path is the branch path determined by the blockchain node for verifying the first block height record; the second branch path is the The branch path determined by the blockchain node to verify the second account data; verify the first block according to the first branch path and the root hash of the state tree in the block header of the first block stored locally Whether the high record is correct; the block header of the first block stored locally is obtained from the blockchain node, and the first block is in the first high record on the blockchain The block corresponding to the highest block height; after determining that the first block height record is correct, verify the root hash of the state tree in
  • the client sends a data acquisition request to the blockchain node, and the blockchain node returns two sets of data to the client according to the client's data acquisition request.
  • the first set is the first high record and is used to verify the first high record.
  • a piece of high-record first branch path, the second group is the second account data and the second branch path used to verify the second account data, so that the client can separately check the first piece of high record and the second branch according to the two sets of data 2.
  • Account data is verified.
  • the first branch path and the second branch path are shorter than the branch paths in the prior art, the time required for the blockchain node to obtain the branch path is shorter, and the time required for client verification is also shorter. , Thereby improving the efficiency of the client to verify data.
  • the verifying whether the first block height record is correct according to the first branch path and the root hash of the state tree in the block header of the first block stored locally includes: according to the first block The high record and the data of the leaf node and the branch node in the first branch path determine the first root hash; if the first root hash is equal to the value of the state tree in the block header of the first block stored locally Root hash, it is determined that the first high record is correct.
  • the client implements the verification of the high record of the first block according to the root hash of the state tree in the block header of the first block stored locally and the first branch path.
  • the verifying whether the second account data is correct according to the second branch path and the root hash of the state tree in the block header of the locally stored second block includes: according to the The second account data and the data of the leaf nodes and branch nodes in the second branch path determine the second root hash; if the second root hash is equal to the state in the block header of the second block stored locally The root hash of the tree determines that the second account data is correct.
  • the client implements the verification of the second account data according to the root hash of the state tree in the block header of the second block stored locally and the second branch path.
  • the method further includes: sending a query request to the blockchain node; receiving a query result returned by the blockchain node; the query result is that the blockchain node receives the query The current block height of the blockchain returned after the request; determine whether the highest block height of the locally stored block header is less than the current block height, and if so, send a block header acquisition request to the blockchain node;
  • the block header obtaining request includes the block height of the block header to be obtained; receiving the block header returned by the blockchain node, and storing the received block header locally.
  • the client regularly goes to the blockchain node to obtain the block header of the latest block, which can ensure that when the account data needs to be verified, the block header information of the block used for verification is stored locally.
  • the method before storing the received block header locally, the method further includes: obtaining N signature information in the received block header; verifying the N signature information according to the consensus node list;
  • the consensus node list is a list of consensus nodes determined from the block header of the genesis block of the blockchain to the previous block header of the received block header; if the N signature information passes verification, then Make sure that the received block header is correct.
  • the verification of the N signature information according to the consensus node list includes: determining the N consensus nodes corresponding to the N signature information; determining that the N consensus nodes are in the consensus node list If M meets the preset conditions, it is determined that the N signature information passes verification.
  • the client verifies the block header information of the genesis block from the beginning of the genesis block, and each time the block header of a block is added, the consensus node in the current consensus node list will be combined with the block header of the currently added block. Verification is to ensure that the block header information of the block saved locally is correct, so as to ensure the correctness of the root hash of the state tree in the block header used to verify the account data, and then to realize the verification of the account data.
  • the present application also provides a device that has the function of realizing any method provided in the above-mentioned first aspect or any method provided in the above-mentioned second aspect.
  • the device can be realized by hardware, or by hardware executing corresponding software.
  • the hardware or software includes one or more units or modules corresponding to the above-mentioned functions.
  • the device includes a processor configured to support the device to execute the steps in the method shown above.
  • the device may also include a memory, which may be coupled with the processor, which stores program instructions and data necessary for the device.
  • the device further includes a communication interface for supporting communication between the device and other devices.
  • the device includes corresponding functional units, which are respectively used to implement the steps in the above method.
  • the function can be realized by hardware, or the corresponding software can be executed by hardware.
  • the hardware or software includes one or more units corresponding to the above-mentioned functions.
  • the embodiments of the present invention also provide a non-transitory computer-readable storage medium.
  • the non-transitory computer-readable storage medium stores computer instructions, and when it runs on a computer, the computer executes the first aspect described above.
  • an embodiment of the present invention also provides a computer program product containing instructions.
  • the computer program product includes a calculation program stored on a non-transitory computer-readable storage medium.
  • the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the state tree generation method of the block in any one of the implementations of the first aspect, or executes the on-chain data verification in any one of the implementations of the second aspect. Methods.
  • Figure 1 is a schematic diagram of a Merkle Tree
  • Figure 2 is a schematic diagram of a state tree and a storage tree in Ethereum in the prior art
  • Figure 3 is a schematic diagram of a state tree and a storage tree provided by an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of another state tree and storage tree provided by an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of the flow of a method for generating a state tree of a block according to an embodiment of the present invention
  • FIG. 6 is a system architecture applicable to on-chain data verification provided by an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of the flow of a method for on-chain data verification according to an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of a process for a client to obtain a block header according to an embodiment of the present invention
  • FIG. 9 is a system architecture applicable to another on-chain data verification provided by an embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of an apparatus for generating a state tree of a block according to an embodiment of the present invention.
  • FIG. 11 is a schematic structural diagram of an on-chain data verification device provided by an embodiment of the present invention.
  • FIG. 12 is a schematic structural diagram of a computing device provided by this application.
  • Merkle Tree is a binary tree composed of leaf nodes, intermediate nodes and root nodes.
  • the leaf node records the hash value of the data (such as account data mentioned in the embodiment of the present invention), and the intermediate node records the calculation after its two child nodes (the child nodes may be leaf nodes or other intermediate nodes) Hash value, the calculation method of the value recorded by the root node is similar to the calculation method of the value recorded by the intermediate node.
  • Merkle Tree can be shown in Figure 1.
  • D1-D7 are basic data (used to build leaf nodes), and H1-H7 records the hash value of the corresponding data (H1-H7 is Is a leaf node). Going up one level, H9 is an intermediate node, and it records the value obtained after hashing with nodes H2 and H1 as inputs. Repeat the above calculation process cyclically, and finally calculate the hash value of the last node, which is the root node, and the recorded hash value is the hash value of the entire Merkle Tree.
  • the blockchain node can provide the Merkle branch path of D1-H10-H14, and the verifier calculates the hash values of D1 and D2 according to the branch path , Then calculate the hash value of H1 and H2, then calculate the hash value with H10, and finally calculate the hash value with H14. If the obtained hash value is consistent with the hash value recorded by the root node, it means that D2 exists in Merkle Tree in.
  • Trie Tree is a search tree, also known as Digital Tree (dictionary tree). Unlike a binary tree, the key value of a Trie Tree is not stored by the nodes in the tree, but depends on its position in the tree (that is, the path from the root node to a specific node). All descendants of a node have the same prefix, which is the string corresponding to this node (the root node corresponds to an empty string). Only leaf nodes have corresponding storage values.
  • dictionary tree Digital Tree
  • Patricia Tree is a more space-saving prefix tree. If a node has no sibling nodes, it is merged with its parent node.
  • Ethereum includes a state tree and a storage tree.
  • the storage tree can be a storage MPT or a storage Merkle Tree.
  • the state tree is composed of Ethereum accounts, and the hash of the root node of the state tree is recorded in the state root field of each block header.
  • the storage tree is a structure for storing data associated with an account. This item is only available for contract accounts. All smart contract data is stored in the storage tree in the form of a 32-byte mapping. The hash value of the root node of the storage tree is recorded in the storage root field of the account.
  • the state MPT or the leaf node storing the MPT records the value of the key-value data item, and the key code is composed of the path from the root node to the leaf node of the MPT.
  • the embodiments of the present invention provide a new construction relationship between the state tree and the storage tree, wherein the state tree and the storage tree are only used to store the account data modified during the execution of the current block transaction, such as new Increased account data or modified account data.
  • the embodiment of the present invention provides a state tree and a storage tree as shown in FIG. 3, which are explained as follows in comparison with FIG. 2:
  • the contract state of Account 175 is modified during the execution of block 60, and 27 becomes 45.
  • the parent is determined based on the contract state 26 of the original Account 175 and the modified contract state 45.
  • the hash value in the node, and the hash value of the root node of the constructed storage tree is stored in the storage root field of Account 175 in block 60; based on the account status of the original Account 174 and the modified Account 175
  • the account state determines the hash value in the parent node, and stores the hash value of the root node of the constructed state tree in the state root field of the block 60.
  • the contract state of Account 175 is modified during the execution of block 60.
  • the hash in the parent node is determined only based on the modified contract state 45 of the current Account 175
  • the hash value of the root node of the constructed storage tree is stored in the storage root field of Account 175 of block 60; the hash value in the parent node is determined based on the account status of the modified Account 175, and the The hash value of the root node of the constructed state tree is stored in the state root field of the block 60.
  • the state tree and the storage tree in the embodiment of the present invention are only generated based on the modified or newly added account data during the transaction execution of the current block, and will not be based on the unchanged data corresponding to the original block.
  • Account data generation. This method can greatly reduce the level of the state tree and storage tree by streamlining the amount of data.
  • the prior art uses 10,000 accounts to construct the state tree corresponding to the block 60, and in the embodiment of the present invention, if only the account data of the 1,000 accounts change after all transactions in the block 60 are executed, the present invention is implemented For example, only 1000 accounts need to be used to construct the state tree corresponding to block 60, and the 1000 accounts build their own storage trees based on the contract data that have changed.
  • the data amount in the embodiment of the present invention is reduced to 1/10 of the original data amount. , Can greatly reduce the level of the state tree and storage tree.
  • the embodiment of the present invention can merge the state tree and the storage tree into one.
  • a tree moves the value in the leaf node of the state tree down to the same level as the value in the leaf node of the storage tree, thereby flattening the hierarchical structure of the account data.
  • the embodiment of the present invention provides a new state tree as shown in FIG. 4.
  • a block corresponds to a state tree.
  • the leaf nodes of the state tree include account state and contract state. In this way, only one Merkle proof is needed to verify the existence of account data. For example, it is necessary to verify that the contract state 27 is in block 60.
  • the level of the state tree It becomes smaller and speeds up the construction and verification efficiency of branch paths.
  • the key used for disk placement storage can be defined as "account ID + account data ID + write/modify the block height of the key-value", and the value value is the account data corresponding to the account data ID.
  • the account identification can be understood as the account address; the account data identification can be understood as the serial number of the data that needs to be stored persistently, or the identification of the data that needs to be stored persistently, for example, the account data is the account balance in the account status, then the account data
  • the identifier can be "balance”.
  • the account data is the value in the contract status, and the account data identifier can be a set serial number.
  • the identifier of the contract status 27 in FIG. 4 is 2.
  • the leaf node in the embodiment of the present invention stores the hash value of the account data.
  • the state tree constructed in the embodiment of the present invention is only constructed based on the change account data of the change account, there is a problem with this construction method, that is, the correctness of a non-existent data cannot be proved, which is equivalent to the inability to prove that a non-existent data is not constituted Whether the account data of the state tree of a block exists in the state tree of the block. For example, if the block height of the current blockchain is 100, there is an account whose account data has only changed when the block height is 20, and the account data of the account can only be verified based on the state tree of the block height of 20 The correctness of the account data cannot be verified based on the state tree of any block after the block height is 20.
  • the embodiment of the present invention will add another set of key-value key-value pairs based on storing the above-mentioned key-value key-value pairs, where the key includes an account identifier and an account data identifier.
  • the account data identifier corresponds to the block height record, and the value value is the block height record.
  • the block height record is used to record the block height of the block where the account data in the account corresponding to the account identifier has been changed.
  • the current block height of the blockchain is 60
  • 0x234_1 is the key of persistent storage
  • 1 is the identifier of the block height record
  • 12-45-50 is the block height record of the record.
  • the current blockchain stores four key-value key-value pairs as shown in Table 1. Among them, the first key-value key-value pair indicates the block height record of the account 0x234, and the second to fourth keys The -value key-value pair indicates the balance value of the account 0x234 when writing or modifying the corresponding block height.
  • FIG. 5 exemplarily shows the flow of a method for generating a state tree of a block provided by an embodiment of the present invention.
  • the flow may be executed by a device for generating a state tree of a block, and the device may be located in Among the blockchain nodes, it can be the blockchain node.
  • step 501 the blockchain node determines the first account and first account data of the block for any block in the blockchain.
  • the first account is the account whose account data changes after the execution of each transaction in the block, and the first account data is the account data after the change in the first account after the execution of each transaction.
  • the blockchain node determines the account involved in each transaction based on each transaction in the current block, and judges whether the account data in the account involved in each transaction has changed, and the account whose account data has changed is the first account.
  • the changed account data is the first account data. There may be one first account data in a first account, or there may be multiple first account data.
  • the first account data that may exist in the first account may include block height records, account status, and/or contract status that have changed in the first account after each transaction is executed.
  • the first account data that can be included in the first account 0x234 of the block 50 has a block height record of 12-45-50 and a balance value of 200.
  • each transaction in the current block involves a total of 100 accounts, and the number of accounts whose account data has changed is 98.
  • the first account corresponding to the current block is 98
  • each of the 98 accounts corresponds to at least one account data that has changed.
  • step 502 the blockchain node constructs a state tree of the block composed of each first account and the first account data of each first account, and stores the root hash of the state tree in the block header of the block.
  • the state tree is stored in the form of key-value pairs.
  • the identification of the first account, the identification of the first account data, and the block height of the block can be used as the key value, and the first account data can be used as the leaf node
  • the value value of the block is based on the MPT mode to build the state tree of the block.
  • the key value is directly stored persistently instead of the hash of the key value.
  • the account data under the same account have the same compressed prefix, that is, the account identifier.
  • the account address as shown in Figure 4, all the keys of the account data of 0x234 have the same prefix, that is, 0x234, so at least the keys of all the account data of 0x234 can be compressed with the common prefix 0x234.
  • the embodiment of the present invention can effectively utilize the advantages of Patricia Tree, compress the level of the state tree to a minimum, reduce storage space, and speed up the construction and verification efficiency of branch paths.
  • the embodiment of the present invention also provides a method for on-chain data verification.
  • the method is suitable for the system architecture shown in FIG. 6, and the system architecture may include a client and a zone.
  • Block chain node the client can be understood as the data user, and the blockchain node can be understood as the data provider; the blockchain node is any blockchain node in the blockchain system that the client can access.
  • Fig. 7 is the flow of the method for on-chain data verification shown in the embodiment of the present invention, and the flow specifically includes:
  • Step 701 The client sends a data acquisition request to the blockchain node.
  • the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height, and the data acquisition request is used to instruct to acquire the value of the second account data of the second account on the first block height.
  • Step 702 The blockchain node determines the first high record according to the identifier of the second account and the identifier of the first high record of the second account.
  • the blockchain node After the blockchain node receives the data acquisition request sent by the client, it will determine the first high record according to the identification of the second account and the identification of the first high record of the second account, as shown in Table 1, the second account The ID is 0x234, and the ID of the first high record of the second account is 1, then the composed key is 0x234_1. According to the key-value key-value pair in the persistent storage, the value corresponding to the key 0x234_1 is determined to be 12-45-50 .
  • Step 703 The blockchain node determines the second account data according to the identification of the second account, the identification of the second account data, and the height of the first block.
  • the blockchain node determines the second account data according to the identification of the second account, the identification of the second account data, and the height of the first block. As shown in Table 1, if the height of the first block is 48, the identification of the second account is determined to be 0x234, the identifier of the second account data is balance, and the composed key is 0x234_balance_45. According to the key-value key-value pair in the persistent storage, the value corresponding to the key 0x234_balance_45 is determined to be 300.
  • step 704 the blockchain node obtains the first branch path for verifying the high record of the first block from the state tree of the first block.
  • Step 705 The blockchain node obtains the second branch path for verifying the second account data from the state tree of the second block.
  • the state tree of a certain block constructed in the embodiment of the invention can only be used to verify the existence of the account data corresponding to the state tree of the block, to verify the existence of the second account data, the second account needs to be determined first The second block corresponding to the state tree where the data is located, and then according to the state tree of the second block, determine the second branch path for verifying the second account data.
  • the second block corresponding to the state tree where the second account data is located it is necessary to determine the block height record recorded when the account data of the second account has been previously modified, that is, the first block height record needs to be determined. After the first block height record is determined, the block corresponding to the highest block height of all block heights lower than the first block height in the first block height record can be used as the second block, and the second block is ready to use After recording the last modified account data of the second account before the first block height, the second branch path for verifying the second account data is determined according to the state tree of the second block.
  • the first block may be the block corresponding to the highest block height in the first block height record.
  • the first branch path is determined by the state tree corresponding to the first block of block height 50, and the second branch path is corresponding to the second block of block height 45 The state tree is determined.
  • step 706 the blockchain node sends the first high record, the first branch path, the second account data, and the second branch path to the client.
  • Step 707 The client verifies whether the first block of high records is correct according to the first branch path and the root hash of the state tree in the block header of the first block stored locally;
  • the client locally stores the block headers of each block on the blockchain, which are used for receiving the first high record, the first branch path, the second account data, and the second branch path sent by the blockchain node.
  • the information in the corresponding block header verifies the first high record and the second account data.
  • the client can periodically go to the blockchain node to obtain the block header of the latest block.
  • the client can go to the blockchain when it needs to verify the received data. Get it on the node.
  • the former can be specifically shown in Figure 8 and completed by the interaction between the client and the blockchain node.
  • Step 801 the client sends a query request to the blockchain node
  • Step 802 the blockchain node sends the current block height of the blockchain to the client;
  • Step 803 The client determines that the highest block height of the locally stored block header is smaller than the current block height
  • Step 804 the client sends a block header acquisition request to the blockchain node
  • Step 805 the blockchain node determines the block header to be obtained by the client
  • Step 806 the blockchain node sends the block header to be obtained to the client
  • step 807 the client receives the block header returned by the blockchain node, and stores the received block header locally.
  • step 801 to step 807 the client sends a query request to the blockchain node.
  • the blockchain node After receiving the query request, the blockchain node will feedback the current block height on the current blockchain to the client, and the client will receive the query request.
  • the query result of the current block height is used to determine whether the block header needs to be synchronized with the blockchain node according to the query result. Specifically, the client determines whether the highest block height of the locally stored block header is less than the current block height on the blockchain. If it is, it is determined to synchronize the block header to the blockchain node, and send a block header acquisition request to the blockchain node, where the block header acquisition request includes the block height of the block header to be acquired.
  • the client determines that it needs to obtain the 99th and 100th from the blockchain node. For the block header of each block, the client sends a block header acquisition request to the blockchain node, where the block header acquisition request includes the block heights of the block header to be acquired as 99 and 100.
  • the client regularly goes to the blockchain node to obtain the block header of the latest block, which can ensure that when the account data needs to be verified, the block header information of the block used for verification is stored locally.
  • the client can determine whether the first block high record is correct according to the first branch path and the root hash of the state tree in the block header of the first block stored locally.
  • the first block stored locally by the client is the block corresponding to the highest block height in the first block height record obtained by the client from the blockchain node.
  • the client determines the first root hash according to the first block of high records and the data of the leaf nodes and branch nodes in the first branch path. If the client determines that the first root hash is equal to the first area stored locally The root hash of the state tree in the block header of the block determines that the first block high record is correct.
  • Step 708 After determining that the first block of high records is correct, the client verifies whether the second account data is correct according to the second branch path and the root hash of the state tree in the block header of the second block stored locally.
  • the client first judges whether the first high record is correct. If it is correct, it can further verify the correctness of the second account data based on the second branch path and the root hash of the state tree in the block header of the second block stored locally.
  • the block header of the second block stored locally by the client is obtained from the blockchain node, the second block is the block corresponding to the second block on the blockchain, and the second block is the first block.
  • the highest block height of all block highs in a block high record lower than the first block height.
  • the client can determine the second root hash according to the second account data and the data of the leaf nodes and branch nodes in the second branch path. If the client determines that the second root hash is equal to the second area stored locally The root hash of the state tree in the block header of the block determines that the second account data is correct.
  • the client first obtains the first block of high records and the second account data, and verifies the first block of high records based on the first block, and based on the second block pair The second account data is verified, but in the embodiment of the present invention, the client may first obtain the first block of high records, and verify the first block of high records based on the first block, and then verify the first block of high records. After passing, the second account data is obtained, and the second account data is verified based on the second block.
  • the client verifies the first block of high records based on the root hash of the state tree of the block header of the first block stored locally, and the state tree based on the block header of the second block stored locally.
  • the root hash of to verify the data of the second account so the client first needs to make sure that the locally stored block header information is correct.
  • the signature list of the node on the chain is added to the block header.
  • the client After obtaining the block header, the client will verify the block header according to the signature list in the block header.
  • the correctness of the block header specifically, before storing the received block header locally, the client obtains the N signature information in the received block header, and verifies the N signature information according to the local consensus node list. If If the N signature information is verified, it is determined that the received block header is correct.
  • the consensus node list is a list of consensus nodes determined by the client according to the block header in the genesis block of the blockchain to the previous block header of the received block header, such as the current block header obtained by the client Is the block header of the 100th block, the client needs to verify the signature information of the current block header based on the consensus node list determined by the block headers of the 0th block (the genesis block) to the 99th block .
  • the consensus nodes in the consensus node list are determined in the genesis block of the blockchain, and may change in subsequent block transactions.
  • the consensus nodes in the consensus node list in the genesis block have A, B, C, D; from the 0th block to the 49th block, the consensus node in the consensus node list in the block header has not changed; at the 50th block, the consensus after the transaction in the block is executed Consensus node E is added to the node list.
  • the consensus nodes in the consensus node list are A, B, C, D, E; the consensus node in the consensus node list from the 50th block to the 99th block No change has occurred; therefore, when the client verifies the N signature information in the 100th block header, it can be based on the consensus node list determined from the 0th block to the 99th block. authenticating.
  • the consensus node list is determined based on the block headers of the 0th block to the 99th block, when verifying the signature information in the block header of the 100th block, the first block is directly used.
  • the list of consensus nodes in the block header of 99 blocks can be verified, because the block header of the 99th block has passed the verification of the consensus node list in the block header of the 98th block, and the block header of the 98th block Has passed the verification of the consensus node list in the block header of the 97th block, and so on, the block header of the second block has passed the verification of the consensus node list in the block header of the first block, the first block
  • the block header of the block has passed the verification of the consensus node list in the block header of the 0th block.
  • the consensus node in the consensus node list changes, which is equivalent to a change in a certain contract data
  • the state tree root hash of the block header of the current block needs to be used to verify the correctness of the contract data
  • using the consensus node list of the block header of the previous block of the current block to verify the signature information in the current block header is equivalent to using the consensus node list of the block header of the previous block of the current block to verify the current block
  • the contract data of the state tree corresponding to the 50th block will change, such as adding a certain contract data (representing consensus Node E), it is necessary to use the root hash of the state tree in the 50th block to verify the existence of the added contract data, and to use the consensus node list of the 49th block for the 50th block.
  • the block header information is verified, that is, the root hash of the state tree in the block header of the 50th block is verified.
  • the POW (Proof of Work) consensus algorithm is adopted, and the preset threshold is N/2+1.
  • the number of consensus nodes is greater than or equal to N/2+1, it represents the block The block header information of is verified, where N is the number of consensus nodes in the consensus list.
  • the client also needs to verify the correctness of the genesis block information.
  • the client verifies that the genesis block information of a certain number of consensus nodes on the blockchain is consistent, it recognizes the genesis block.
  • the specific number here may be the aforementioned preset threshold.
  • the client verifies the block header information of the genesis block from the beginning of the genesis block, and each time the block header of a block is added, the consensus node in the current consensus node list will be combined with the block header of the currently added block. Verification is to ensure that the block header information of the block saved locally is correct, so as to ensure the correctness of the root hash of the state tree in the block header used to verify the account data, and then to realize the verification of the account data.
  • the verification flow is creation block ⁇ consensus node ⁇ block header information ⁇ state tree root hash ⁇ account data, that is, the creation block verifies the consensus node.
  • the consensus node verifies the block header information
  • the block header information verifies the state tree root hash
  • the state tree root hash verifies the account data.
  • the state tree is constructed, based on the one-way nature of the hash calculation, once the leaf node (account data) is modified, the root hash of the state tree will be changed, that is, to further ensure that the account data is not modified.
  • the above-mentioned relevant verification point information is provided by the nodes on the chain. For consortium chains with the concept of access, the nodes on the chain need to perform authentication before providing information to the client to further ensure the accuracy of data verification.
  • the client requests the blockchain node to obtain the balance of the account 0x234 on the block height 48.
  • the blockchain node first determines the first block height record 12-45-50 according to 0x234_1, and the blockchain node according to the block height 50
  • the state tree of the first block determines the first branch path used to verify the first block of high record 12-45-50; the blockchain node determines the first branch according to the first block of high record 12-45-50 and block height 48
  • the block height record is smaller than the block height 48 and the largest block height is 45.
  • the blockchain node first determines the balance to be 300 according to 0x234_balance_45, and determines the second block used to verify the balance 300 according to the state tree of the second block with a block height of 45 Branch path.
  • the blockchain node sends the first block of high record 12-45-50, the first branch path, balance 300, and the second branch path to the client, and the client uses the locally stored block height 50 of the first block.
  • Block header combined with the first branch path to verify the correctness of the first block of high record 12-45-50, based on the proven first block of high record 12-45-50, determine that the balance is modified at block 45, then use the local
  • the stored block header of the second block with a block height of 45 is combined with the verification of the second branch path to verify the correctness of the balance 300.
  • the client has completed the process of querying and verifying that the balance of account 0x234 on the block with block height 48 is 300.
  • the client in FIG. 6 may also be a blockchain node of an alliance chain different from the blockchain node.
  • it may include a first blockchain node and a second blockchain node; where , The first blockchain node can be understood as the data user, and the second blockchain node can be understood as the data provider; the first blockchain node and the second blockchain node belong to different alliance chains.
  • FIG. 10 exemplarily shows the structure of an apparatus for generating a state tree of a block provided by an embodiment of the present invention, and the apparatus can execute the flow of the method for generating a state tree of a block.
  • the device includes: a determining unit 1001 for determining a first account and first account data of the block for any block in the block chain; the first account is the execution of each transaction in the block After the account data has changed, the first account data is the account data after the change in the first account after the execution of each transaction; the construction unit 1002 is used to construct the first account and the first account.
  • the first account data of the first account constitutes the state tree of the block, and the root hash of the state tree is stored in the block header of the block, wherein the state tree is a key-value pair Way to store.
  • the construction unit 1002 is specifically configured to: for any first account data of any first account, combine the identification of the first account, the identification of the first account data, and the identification of the block
  • the block height is used as the key value
  • the first account data is used as the value value of the leaf node
  • the state tree of the block is constructed based on the MPT mode.
  • the first account data includes a block height record, an account status, and/or a contract status that have changed in the first account after the execution of each transaction; the block height record is used to record the first The block height of the block where the account status and/or contract status in the account has been changed.
  • the device further includes a processing unit 1003; the processing unit 1003 is configured to: receive a data acquisition request from the client; the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first Block height; determine the first block height record according to the identification of the second account and the identification of the first block height record of the second account; according to the identification of the second account and the second account data The identification of the first block height, the second account data is determined; the first branch path used to verify the first block height record is obtained from the state tree of the first block; the first block Is the block corresponding to the highest block height in the first block height record; the second branch path for verifying the second account data is obtained from the state tree of the second block; the second block is The block corresponding to the second block height; the second block height is the highest block height of all block heights lower than the first block height in the first block height record; the first block height is recorded , The first branch path, the second account data, and the second branch path are sent to the client,
  • FIG. 11 exemplarily shows the structure of an on-chain data verification device provided by an embodiment of the present invention, and the device can execute the flow of the on-chain data verification method.
  • the device includes: a transceiver unit 1101, configured to send a data acquisition request to a blockchain node; the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height; the transceiver unit 1101, It is also used to receive the first block of high records, the first branch path, the second account data, and the second branch path returned by the blockchain node; the first block of high records and the second account data are the The blockchain node is determined according to the identification of the second account, the identification of the second account data, and the first block height; the first branch path is determined by the blockchain node for verification The branch path of the first block of high records; the second branch path is the branch path determined by the blockchain node for verifying the second account data; the verification unit 1102 is configured to follow the first branch Path, the root hash of the state tree in the block header of the first block stored locally to verify whether the first block high record is correct; the block header of the first block stored locally is from the blockchain node The first block is the block
  • the verification unit 1102 is specifically configured to: determine the first root hash according to the first block height record and the data of leaf nodes and branch nodes in the first branch path; if the first root If the hash is equal to the root hash of the state tree in the block header of the first block stored locally, it is determined that the high record of the first block is correct.
  • the verification unit 1102 is specifically configured to: determine a second root hash according to the second account data and data of leaf nodes and branch nodes in the second branch path; If it is equal to the root hash of the state tree in the block header of the locally stored second block, it is determined that the second account data is correct.
  • the device further includes a synchronization unit 1103; the synchronization unit 1103 is configured to: send a query request to the blockchain node; receive the query result returned by the blockchain node; the query result is all The current block height of the block chain returned by the block chain node after receiving the query request; determine whether the highest block height of the locally stored block header is less than the current block height, and if so, send it to the district
  • the block chain node sends a block header acquisition request; the block header acquisition request includes the block height of the block header to be acquired; receives the block header returned by the blockchain node, and stores the received block header locally.
  • the synchronization unit 1103 is further configured to: obtain N signature information in the received block header; N signature information verification; the consensus node list is a list of consensus nodes determined from the block header of the genesis block of the blockchain to the previous block header of the received block header; if the N If the signature information is verified, it is determined that the received block header is correct.
  • the synchronization unit 1103 is specifically configured to: determine the N consensus nodes corresponding to the N signature information; determine the M consensus nodes in the consensus node list among the N consensus nodes; if M If the preset condition is met, it is determined that the N signature information passes the verification.
  • the present application also provides a computing device.
  • the computing device includes at least one processor 1220 for implementing the method provided in the embodiment of the present application. Either method in Figure 5 or Figure 7.
  • the computing device 1200 may also include at least one memory 1230 for storing program instructions and/or data.
  • the memory 1230 and the processor 1220 are coupled.
  • the coupling in the embodiments of the present application is an indirect coupling or communication connection between devices, units or modules, and may be in electrical, mechanical or other forms, and is used for information exchange between devices, units or modules.
  • the processor 1220 may operate in cooperation with the memory 1230.
  • the processor 1220 may execute program instructions stored in the memory 1230. At least one of the at least one memory may be included in the processor.
  • each step of the above method can be completed by an integrated logic circuit of hardware in the processor or instructions in the form of software.
  • the steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware processor, or executed and completed by a combination of hardware and software modules in the processor.
  • the software module can be located in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers.
  • the storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware. To avoid repetition, it will not be described in detail here.
  • the processor in the embodiment of the present application may be an integrated circuit chip with signal processing capability.
  • the steps of the foregoing method embodiments can be completed by hardware integrated logic circuits in the processor or instructions in the form of software.
  • the above-mentioned processor may be a general-purpose processor, a digital signal processing circuit (digital signal processor, DSP), a dedicated integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field programmable gate array, FPGA) or other Programming logic devices, discrete gates or transistor logic devices, discrete hardware components.
  • DSP digital signal processing circuit
  • ASIC application specific integrated circuit
  • FPGA field programmable gate array
  • Programming logic devices discrete gates or transistor logic devices, discrete hardware components.
  • the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
  • the steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers.
  • the storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
  • the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory.
  • the non-volatile memory can be read-only memory (ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), and electrically available Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory.
  • the volatile memory may be random access memory (RAM), which is used as an external cache.
  • RAM random access memory
  • static random access memory static random access memory
  • dynamic RAM dynamic RAM
  • DRAM dynamic random access memory
  • synchronous dynamic random access memory synchronous DRAM, SDRAM
  • double data rate synchronous dynamic random access memory double data rate SDRAM, DDR SDRAM
  • enhanced synchronous dynamic random access memory enhanced SDRAM, ESDRAM
  • synchronous connection dynamic random access memory serial DRAM, SLDRAM
  • direct rambus RAM direct rambus RAM
  • the computing device 1200 may further include a communication interface 1210 for communicating with other devices through a transmission medium, so that the device used in the computing device 1200 can communicate with other devices.
  • the communication interface may be a transceiver, circuit, bus, module, or other type of communication interface.
  • the transceiver when the communication interface is a transceiver, the transceiver may include an independent receiver and an independent transmitter; it may also be a transceiver with integrated transceiver functions, or an interface circuit.
  • the computing device 1200 may also include a communication line 1240.
  • the communication interface 1210, the processor 1220, and the memory 1230 may be connected to each other through a communication line 1240;
  • the communication line 1240 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (extended industry standard architecture). , Referred to as EISA) bus and so on.
  • the communication line 1240 can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 12 to represent it, but it does not mean that there is only one bus or one type of bus.
  • the embodiments of the present invention also provide a non-transitory computer-readable storage medium.
  • the non-transitory computer-readable storage medium stores computer instructions, and when it runs on a computer, the computer executes as shown in Figure 5.
  • inventions of the present application provide a computer program product.
  • the computer program product includes a calculation program stored on a non-transitory computer-readable storage medium.
  • the computer program includes program instructions. When executed by a computer, the computer is caused to execute the method of generating the state tree of the block in the related embodiment of FIG. 5, or execute the method of on-chain data verification in the related embodiment of FIG. 7.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.

Abstract

Disclosed are methods and apparatus for generating a state tree of a block and validating on-chain data. The method for generating a state tree of a block comprises: determining for any block in a blockchain a first account and first account data of the block, the first account being an account in which account data is changed after each transaction is executed in the block, and the first account data being changed account data in the first account after each transaction is executed; and constructing a state tree of a block formed from each first account and first account data of each first account, and storing a root hash of the state tree in a block header of the block, the state tree being stored as a key-value pair. The described technical solution is used to simplify account data used for constructing a state tree on a blockchain, thereby shortening the length of a branch path used for validation, and improving the efficiency of existence validation of account data.

Description

一种区块的状态树的生成和链上数据验证的方法及装置Method and device for generating block state tree and verifying data on chain
相关申请的交叉引用Cross-references to related applications
本申请要求在2019年10月10日提交中国专利局、申请号为201910960376.X、申请名称为“一种区块的状态树的生成和链上数据验证的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application requires a Chinese patent application to be submitted to the Chinese Patent Office on October 10, 2019, with an application number of 201910960376.X, and an application titled "Method and device for generating a state tree of a block and verifying data on the chain" Priority, the entire content of which is incorporated in this application by reference.
技术领域Technical field
本发明实施例涉及金融科技(Fintech)领域,尤其涉及一种区块(Block)的状态树的生成和链上数据验证的方法及装置。The embodiments of the present invention relate to the field of financial technology (Fintech), and in particular to a method and device for generating a block state tree and verifying data on a chain.
背景技术Background technique
随着计算机技术的发展,越来越多的技术(例如:区块链(BlockChain)、云计算或大数据)应用在金融领域,传统金融业正在逐步向金融科技转变,区块链技术也不例外,但由于金融、支付行业的安全性、实时性要求,也对区块链技术提出的更高的要求。With the development of computer technology, more and more technologies (such as BlockChain, cloud computing or big data) are applied in the financial field. The traditional financial industry is gradually transforming to financial technology, and blockchain technology is not Exceptions, but due to the security and real-time requirements of the financial and payment industries, higher requirements are also placed on blockchain technology.
以太坊(ethereum)的状态树和存储树中,若对存储树中的合约状态进行存在性验证,需要先确定合约状态在存储树中的分支路径,验证该合约状态是否存在于对应的存储树中,随后确定该存储树所对应的账户状态在状态树中的分支路径,进而验证该账户状态是否存在于对应的状态树中。In the state tree and storage tree of Ethereum (ethereum), if the existence of the contract state in the storage tree is verified, the branch path of the contract state in the storage tree needs to be determined first to verify whether the contract state exists in the corresponding storage tree Then, the branch path of the account state corresponding to the storage tree in the state tree is determined, and then it is verified whether the account state exists in the corresponding state tree.
但随着区块链上数据不断增长,区块链节点需要获取的用于验证的分支路径较长,获取分支路径的耗时和存在性验证的耗时都较长。However, as the data on the blockchain continues to grow, the branch path that blockchain nodes need to obtain for verification is longer, and the time consuming to obtain the branch path and the time consuming to verify the existence are both longer.
发明内容Summary of the invention
本发明实施例提供一种区块的状态树的生成和链上数据验证的方法及装置,用以精简区块链上用于构建状态树的账户数据,从而缩短用于验证的分支路径的长度,提高账户数据的存在性验证的效率。The embodiment of the present invention provides a method and device for generating the state tree of a block and verifying data on the chain, which is used to streamline the account data used to construct the state tree on the block chain, thereby shortening the length of the branch path for verification , Improve the efficiency of the existence verification of account data.
第一方面,本发明实施例提供的一种区块的状态树的生成方法,包括:In the first aspect, a method for generating a state tree of a block provided by an embodiment of the present invention includes:
针对区块链中的任一区块,确定所述区块的第一账户和第一账户数据;所述第一账户是所述区块中各交易执行后账户数据发生变化的账户,所述第一账户数据是所述各交易执行后所述第一账户中发生变化后的账户数据;构建由各第一账户和所述各第一账户的第一账户数据构成的所述区块的状态树,并将所述状态树的根哈希存储在所述区块的区块头中,其中,所述状态树以键值对的方式存储。For any block in the block chain, determine the first account and first account data of the block; the first account is the account whose account data changes after the execution of each transaction in the block, the The first account data is the changed account data in the first account after the execution of each transaction; the state of the block composed of each first account and the first account data of each first account is constructed And store the root hash of the state tree in the block header of the block, wherein the state tree is stored in a key-value pair.
上述技术方案中,在构建状态树时,仅基于当前区块交易执行过程中所修改的或新增的账户数据生成,而不会再基于原有区块对应的未发生变化的账户数据生成,该方式通过精简数据量,可以极大地减少状态树层级。In the above technical solution, when constructing the state tree, it is only generated based on the modified or newly added account data during the execution of the current block transaction, and will not be generated based on the unchanged account data corresponding to the original block. This method can greatly reduce the level of the state tree by reducing the amount of data.
可选的,所述构建由各第一账户和所述各第一账户的第一账户数据构成的所述区块的状态树,包括:针对任一第一账户的任一第一账户数据,将所述第一账户的标识、所述第一账户数据的标识和所述区块的块高作为key值,所述第一账户数据作为叶子节点的value值,基于MPT模式构建所述区块的状态树。Optionally, the constructing the state tree of the block composed of each first account and the first account data of each first account includes: any first account data for any first account, The identification of the first account, the identification of the first account data, and the block height of the block are used as the key value, and the first account data is used as the value value of the leaf node, and the block is constructed based on the MPT mode State tree.
上述技术方案中,直接将key值进行持久化存储,而不是将key值的哈希进行持久化 存储,通过该方式,可以保障同一账户下的账户数据具有相同的压缩前缀,也就是账号标识或账户地址,有效利用Patricia Tree的优势,将状态树的层级压缩至最小,减少存储空间的同时也加快了分支路径的构建及验证效率。In the above technical solution, the key value is directly stored persistently instead of the hash of the key value. In this way, it can be ensured that the account data under the same account has the same compression prefix, that is, the account ID or The account address effectively uses the advantages of Patricia Tree to minimize the level of the state tree, reducing storage space and speeding up the construction and verification efficiency of branch paths.
可选的,所述第一账户数据包括所述各交易执行后所述第一账户中发生变化的块高记录、账户状态和/或合约状态;所述块高记录用于记录所述第一账户中的账户状态和/或合约状态发生历次变化时所在的区块的块高。Optionally, the first account data includes a block height record, an account status, and/or a contract status that have changed in the first account after the execution of each transaction; the block height record is used to record the first The block height of the block where the account status and/or contract status in the account has been changed.
账户状态原本属于状态树的叶子节点中的值,合约状态原本属于存储树的叶子节点中的值,而上述技术方案中,将状态树的叶子节点中的值下移至与存储树的叶子节点中的值平级,将状态树和存储树合并为一棵树,从而扁平化账户数据的层级结构,加快了分支路径的构建及验证效率。进一步的,在落盘存储时增加key-value键值对,其中,该key中包括账户标识和账户数据标识,此时的账户数据标识对应块高记录,value值即为块高记录,该块高记录用于记录账户标识对应账户中的账户数据发生历次变化时所在的区块的块高,通过该方式,可以在验证某个账户数据时,先确定该账户数据所在状态树的区块,进而根据该区块确定用于验证的分支路径。The account state originally belongs to the value in the leaf node of the state tree, and the contract state originally belongs to the value in the leaf node of the storage tree. In the above technical solution, the value in the leaf node of the state tree is moved down to the leaf node of the storage tree. The value level in, merges the state tree and the storage tree into one tree, thereby flattening the hierarchical structure of the account data, and speeding up the construction and verification efficiency of the branch path. Further, a key-value key-value pair is added when placing the disk for storage, where the key includes an account identifier and an account data identifier. At this time, the account data identifier corresponds to the block height record, and the value value is the block height record. The high record is used to record the block height of the block where the account data in the account ID corresponds to the previous change. In this way, when verifying a certain account data, the block of the state tree where the account data is located can be determined first. Then determine the branch path for verification based on the block.
可选的,所述方法还包括:接收客户端的数据获取请求;所述数据获取请求中包括第二账户的标识、第二账户数据的标识和第一块高;根据所述第二账户的标识和所述第二账户的第一块高记录的标识,确定所述第一块高记录;根据所述第二账户的标识、所述第二账户数据的标识、所述第一块高,确定所述第二账户数据;从第一区块的状态树中获取用于验证所述第一块高记录的第一分支路径;所述第一区块是所述第一块高记录中的最高块高对应的区块;从第二区块的状态树中获取用于验证所述第二账户数据的第二分支路径;所述第二区块是第二块高对应的区块;所述第二块高是所述第一块高记录中低于所述第一块高的所有块高中的最高的块高;将所述第一块高记录、所述第一分支路径、所述第二账户数据、所述第二分支路径发送至所述客户端,以使所述客户端对所述第一块高记录和第二账户数据进行验证。Optionally, the method further includes: receiving a data acquisition request from the client; the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height; according to the identifier of the second account And the identifier of the first high record of the second account, determine the first high record; determine according to the identifier of the second account, the identifier of the second account data, and the first high record The second account data; the first branch path used to verify the first block of high records is obtained from the state tree of the first block; the first block is the highest in the first block of high records The block corresponding to the block height; obtain the second branch path for verifying the second account data from the state tree of the second block; the second block is the block corresponding to the second block height; the The second block height is the highest block height of all block heights lower than the first block height in the first block height record; the first block height record, the first branch path, and the first block height are recorded. 2. The account data and the second branch path are sent to the client, so that the client verifies the first high record and the second account data.
上述技术方案中,区块链节点根据客户端的数据获取请求,向客户端返回两组数据,第一组是第一块高记录和用于验证第一块高记录的第一分支路径,第二组是第二账户数据和用于验证第二账户数据的第二分支路径,从而客户端可以根据该两组数据分别对第一块高记录和第二账户数据进行验证。其中,第一分支路径和第二分支路径相比于现有技术中的分支路径都较短,区块链节点在获取分支路径时所需时长较短,且客户端验证所需时长也较短,从而提高客户端验证数据的效率。In the above technical solution, the blockchain node returns two sets of data to the client according to the client's data acquisition request. The first set is the first high record and the first branch path used to verify the first high record, and the second The group is the second account data and the second branch path used to verify the second account data, so the client can verify the first high record and the second account data respectively according to the two sets of data. Among them, the first branch path and the second branch path are shorter than the branch paths in the prior art, the time required for the blockchain node to obtain the branch path is shorter, and the time required for client verification is also shorter. , Thereby improving the efficiency of the client to verify data.
第二方面,本发明实施例提供的一种链上数据验证的方法,包括:In the second aspect, an on-chain data verification method provided by an embodiment of the present invention includes:
向区块链节点发送数据获取请求;所述数据获取请求包括第二账户的标识、第二账户数据的标识和第一块高;接收所述区块链节点返回的第一块高记录、第一分支路径、第二账户数据、第二分支路径;所述第一块高记录和所述第二账户数据是所述区块链节点根据所述第二账户的标识、所述第二账户数据的标识和所述第一块高确定的;所述第一分支路径是所述区块链节点确定的用于验证所述第一块高记录的分支路径;所述第二分支路径是所述区块链节点确定的用于验证所述第二账户数据的分支路径;根据所述第一分支路径、本地存储的第一区块的区块头中状态树的根哈希验证所述第一块高记录是否正确;所述本地存储的第一区块的区块头是从所述区块链节点上获取的,所述第一区块是区块链上是所述第一块高记录中的最高块高对应的区块;在确定所述第一块高记录正确之后,根据所述 第二分支路径、所述本地存储的第二区块的区块头中状态树的根哈希,验证所述第二账户数据的是否正确;所述本地存储的第二区块的区块头是从所述区块链节点上获取的,所述第二区块是所述区块链上第二块高对应的区块;所述第二块高是所述第一块高记录中低于所述第一块高的所有块高中的最高的块高。Send a data acquisition request to the blockchain node; the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height; receive the first block height record and the first block height returned by the blockchain node A branch path, second account data, and a second branch path; the first block of high records and the second account data are based on the identification of the second account and the second account data by the blockchain node And the first block height; the first branch path is the branch path determined by the blockchain node for verifying the first block height record; the second branch path is the The branch path determined by the blockchain node to verify the second account data; verify the first block according to the first branch path and the root hash of the state tree in the block header of the first block stored locally Whether the high record is correct; the block header of the first block stored locally is obtained from the blockchain node, and the first block is in the first high record on the blockchain The block corresponding to the highest block height; after determining that the first block height record is correct, verify the root hash of the state tree in the block header of the locally stored second block according to the second branch path Whether the second account data is correct; the block header of the locally stored second block is obtained from the block chain node, and the second block is the second block on the block chain. Corresponding block; the second block height is the highest block height of all block heights lower than the first block height in the first block height record.
上述技术方案中,客户端向区块链节点发送数据获取请求,区块链节点根据客户端的数据获取请求,向客户端返回两组数据,第一组是第一块高记录和用于验证第一块高记录的第一分支路径,第二组是第二账户数据和用于验证第二账户数据的第二分支路径,从而客户端可以根据该两组数据分别对第一块高记录和第二账户数据进行验证。其中,第一分支路径和第二分支路径相比于现有技术中的分支路径都较短,区块链节点在获取分支路径时所需时长较短,且客户端验证所需时长也较短,从而提高客户端验证数据的效率。In the above technical solution, the client sends a data acquisition request to the blockchain node, and the blockchain node returns two sets of data to the client according to the client's data acquisition request. The first set is the first high record and is used to verify the first high record. A piece of high-record first branch path, the second group is the second account data and the second branch path used to verify the second account data, so that the client can separately check the first piece of high record and the second branch according to the two sets of data 2. Account data is verified. Among them, the first branch path and the second branch path are shorter than the branch paths in the prior art, the time required for the blockchain node to obtain the branch path is shorter, and the time required for client verification is also shorter. , Thereby improving the efficiency of the client to verify data.
可选的,所述根据所述第一分支路径、本地存储的第一区块的区块头中状态树的根哈希验证所述第一块高记录是否正确,包括:根据所述第一块高记录和所述第一分支路径中叶子节点和分支节点的数据,确定第一根哈希;若所述第一根哈希等于所述本地存储的第一区块的区块头中状态树的根哈希,则确定所述第一块高记录正确。Optionally, the verifying whether the first block height record is correct according to the first branch path and the root hash of the state tree in the block header of the first block stored locally includes: according to the first block The high record and the data of the leaf node and the branch node in the first branch path determine the first root hash; if the first root hash is equal to the value of the state tree in the block header of the first block stored locally Root hash, it is determined that the first high record is correct.
上述技术方案中,客户端根据本地存储的第一区块的区块头中状态树的根哈希和第一分支路径,实现对第一块高记录的验证。In the above technical solution, the client implements the verification of the high record of the first block according to the root hash of the state tree in the block header of the first block stored locally and the first branch path.
可选的,所述根据所述第二分支路径、所述本地存储的第二区块的区块头中状态树的根哈希,验证所述第二账户数据的是否正确,包括:根据所述第二账户数据和所述第二分支路径中叶子节点和分支节点的数据,确定第二根哈希;若所述第二根哈希等于所述本地存储的第二区块的区块头中状态树的根哈希,则确定所述第二账户数据正确。Optionally, the verifying whether the second account data is correct according to the second branch path and the root hash of the state tree in the block header of the locally stored second block includes: according to the The second account data and the data of the leaf nodes and branch nodes in the second branch path determine the second root hash; if the second root hash is equal to the state in the block header of the second block stored locally The root hash of the tree determines that the second account data is correct.
上述技术方案中,客户端根据本地存储的第二区块的区块头中状态树的根哈希和第二分支路径,实现对第二账户数据的验证。In the above technical solution, the client implements the verification of the second account data according to the root hash of the state tree in the block header of the second block stored locally and the second branch path.
可选的,所述方法还包括:向所述区块链节点发送查询请求;接收所述区块链节点返回的查询结果;所述查询结果是所述区块链节点在接收到所述查询请求后返回的区块链的当前块高;判断所述本地存储的区块头的最高块高是否小于所述当前块高,若是,则向所述区块链节点发送区块头获取请求;所述区块头获取请求中包括待获取区块头的块高;接收所述区块链节点返回的区块头,将接收到的区块头存储在本地。Optionally, the method further includes: sending a query request to the blockchain node; receiving a query result returned by the blockchain node; the query result is that the blockchain node receives the query The current block height of the blockchain returned after the request; determine whether the highest block height of the locally stored block header is less than the current block height, and if so, send a block header acquisition request to the blockchain node; The block header obtaining request includes the block height of the block header to be obtained; receiving the block header returned by the blockchain node, and storing the received block header locally.
上述技术方案中,客户端定时去区块链节点获取最新区块的区块头,可以保障在需要对账户数据进行验证时,本地存储有用于验证的区块的区块头信息。In the above technical solution, the client regularly goes to the blockchain node to obtain the block header of the latest block, which can ensure that when the account data needs to be verified, the block header information of the block used for verification is stored locally.
可选的,所述将接收到的区块头存储在本地之前,还包括:获取所述接收到的区块头中的N个签名信息;根据共识节点列表,对所述N个签名信息验证;所述共识节点列表是根据所述区块链的创世块的区块头至所述接收到的区块头的前一个区块头确定的共识节点组成的列表;若所述N个签名信息通过验证,则确定所述接收到的区块头正确。Optionally, before storing the received block header locally, the method further includes: obtaining N signature information in the received block header; verifying the N signature information according to the consensus node list; The consensus node list is a list of consensus nodes determined from the block header of the genesis block of the blockchain to the previous block header of the received block header; if the N signature information passes verification, then Make sure that the received block header is correct.
可选的,所述根据共识节点列表,对所述N个签名信息验证,包括:确定所述N个签名信息对应的N个共识节点;判断所述N个共识节点中在所述共识节点列表中的M个共识节点;若M符合预设条件,则确定所述N个签名信息通过验证。Optionally, the verification of the N signature information according to the consensus node list includes: determining the N consensus nodes corresponding to the N signature information; determining that the N consensus nodes are in the consensus node list If M meets the preset conditions, it is determined that the N signature information passes verification.
通过上述方式,客户端从创世块开始即对创世块的块头信息进行验证,且每增加一个区块的块头,都会结合当前共识节点列表中的共识节点对当前增加的区块的块头进行验证,以保障保存至本地的区块的块头信息是正确的,从而保障用于验证账户数据的区块头中状态树的根哈希的正确性,进而实现对账户数据的验证。Through the above method, the client verifies the block header information of the genesis block from the beginning of the genesis block, and each time the block header of a block is added, the consensus node in the current consensus node list will be combined with the block header of the currently added block. Verification is to ensure that the block header information of the block saved locally is correct, so as to ensure the correctness of the root hash of the state tree in the block header used to verify the account data, and then to realize the verification of the account data.
第三方面,本申请还提供一种装置,该装置具有实现上述第一方面提供的任一方法或上述第二方面提供的任一方法的功能。该装置可以通过硬件实现,也可以通过硬件执行相应的软件实现。该硬件或软件包括一个或多个与上述功能相对应的单元或模块。In a third aspect, the present application also provides a device that has the function of realizing any method provided in the above-mentioned first aspect or any method provided in the above-mentioned second aspect. The device can be realized by hardware, or by hardware executing corresponding software. The hardware or software includes one or more units or modules corresponding to the above-mentioned functions.
在一种可能的实现方式中,该装置包括:处理器,该处理器被配置为支持该装置执行以上所示方法中步骤。该装置还可以包括存储器,该存储器可以与处理器耦合,其保存该装置必要的程序指令和数据。可选地,该装置还包括通信接口,该通信接口用于支持该装置与其他装置之间的通信。In a possible implementation manner, the device includes a processor configured to support the device to execute the steps in the method shown above. The device may also include a memory, which may be coupled with the processor, which stores program instructions and data necessary for the device. Optionally, the device further includes a communication interface for supporting communication between the device and other devices.
在一种可能的实现方式中,该装置包括相应的功能单元,分别用于实现以上方法中的步骤。功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括一个或多个与上述功能相对应的单元。In a possible implementation manner, the device includes corresponding functional units, which are respectively used to implement the steps in the above method. The function can be realized by hardware, or the corresponding software can be executed by hardware. The hardware or software includes one or more units corresponding to the above-mentioned functions.
第四方面,本发明实施例还提供了一种非暂态计算机可读存储介质,非暂态计算机可读存储介质中存储计算机指令,当其在计算机上运行时,使得计算机执行上述第一方面中任一种实现方式中的区块的状态树的生成方法,或执行上述第二方面中任一种实现方式中的链上数据验证的方法。In a fourth aspect, the embodiments of the present invention also provide a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium stores computer instructions, and when it runs on a computer, the computer executes the first aspect described above. The method for generating the state tree of the block in any one of the implementation manners, or the method for performing on-chain data verification in any one of the implementation manners of the second aspect described above.
第五方面,本发明实施例还提供一种包含指令的计算机程序产品,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使得计算机执行上述第一方面中任一种实现方式中的区块的状态树的生成方法,或执行上述第二方面中任一种实现方式中的链上数据验证的方法。In a fifth aspect, an embodiment of the present invention also provides a computer program product containing instructions. The computer program product includes a calculation program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the state tree generation method of the block in any one of the implementations of the first aspect, or executes the on-chain data verification in any one of the implementations of the second aspect. Methods.
附图说明Description of the drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简要介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域的普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the technical solutions in the embodiments of the present invention more clearly, the following will briefly introduce the drawings needed in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative work, other drawings can be obtained based on these drawings.
图1为一种Merkle Tree的示意图;Figure 1 is a schematic diagram of a Merkle Tree;
图2为现有技术中以太坊中状态树和存储树的示意图;Figure 2 is a schematic diagram of a state tree and a storage tree in Ethereum in the prior art;
图3为本发明实施例提供的一种状态树和存储树的示意图;Figure 3 is a schematic diagram of a state tree and a storage tree provided by an embodiment of the present invention;
图4为本发明实施例提供的另一种状态树和存储树的示意图;4 is a schematic diagram of another state tree and storage tree provided by an embodiment of the present invention;
图5为本发明实施例提供的一种区块的状态树的生成方法的流程的示意图;5 is a schematic diagram of the flow of a method for generating a state tree of a block according to an embodiment of the present invention;
图6为本发明实施例提供的一种链上数据验证所适用的系统架构;FIG. 6 is a system architecture applicable to on-chain data verification provided by an embodiment of the present invention;
图7为本发明实施例提供的一种链上数据验证的方法的流程的示意图;FIG. 7 is a schematic diagram of the flow of a method for on-chain data verification according to an embodiment of the present invention;
图8为本发明实施例提供的一种客户端获取区块头的流程的示意图;8 is a schematic diagram of a process for a client to obtain a block header according to an embodiment of the present invention;
图9为本发明实施例提供的另一种链上数据验证所适用的系统架构;FIG. 9 is a system architecture applicable to another on-chain data verification provided by an embodiment of the present invention;
图10为本发明实施例提供的一种区块的状态树的生成装置的结构示意图;FIG. 10 is a schematic structural diagram of an apparatus for generating a state tree of a block according to an embodiment of the present invention;
图11为本发明实施例提供的一种链上数据验证的装置的结构示意图;11 is a schematic structural diagram of an on-chain data verification device provided by an embodiment of the present invention;
图12为本申请提供的一种计算设备的结构示意图。FIG. 12 is a schematic structural diagram of a computing device provided by this application.
具体实施方式Detailed ways
为了使本发明的目的、技术方案和优点更加清楚,下面将结合附图对本发明作进一步地详细描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。 基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本发明保护的范围。In order to make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of them. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the protection scope of the present invention.
为了更好的解释本发明,先对本发明所涉及的专业术语解释如下:In order to better explain the present invention, first explain the technical terms involved in the present invention as follows:
1、Merkle Tree(默克尔树)1. Merkle Tree
Merkle Tree是一种由叶子节点、中间节点和根节点构成的二叉树。其中叶子节点记录的是数据(如本发明实施例中提及账户数据)的哈希值,中间节点记录的是它的两个子节点(子节点可能为叶子节点或者其他中间节点)组成后计算的哈希值,根节点所记录值的计算方法与中间节点所记录值的计算方法类似。Merkle Tree is a binary tree composed of leaf nodes, intermediate nodes and root nodes. The leaf node records the hash value of the data (such as account data mentioned in the embodiment of the present invention), and the intermediate node records the calculation after its two child nodes (the child nodes may be leaf nodes or other intermediate nodes) Hash value, the calculation method of the value recorded by the root node is similar to the calculation method of the value recorded by the intermediate node.
Merkle Tree可如图1所示,Merkle Tree自底向上的构建流程为,D1-D7是基础数据(用于构建叶子节点),H1-H7记录的是相应数据的哈希值(H1-H7即为叶子节点)。往上一层,H9是中间节点,记录的是将节点H2和H1作为输入进行哈希运算后得到的值。循环重复上述计算过程,最后计算得到最后一个节点的哈希值,该节点为根节点,所记录的哈希值为整棵Merkle Tree的哈希值。Merkle Tree can be shown in Figure 1. The bottom-up construction process of Merkle Tree is, D1-D7 are basic data (used to build leaf nodes), and H1-H7 records the hash value of the corresponding data (H1-H7 is Is a leaf node). Going up one level, H9 is an intermediate node, and it records the value obtained after hashing with nodes H2 and H1 as inputs. Repeat the above calculation process cyclically, and finally calculate the hash value of the last node, which is the root node, and the recorded hash value is the hash value of the entire Merkle Tree.
2、Merkle证明2. Merkle proof
从Merkle Tree的构建过程我们可以发现任意一个叶子节点所记录的数据被修改,叶子节点的哈希值会相应的改变,最终影响到根节点的哈希值。因此根节点的哈希值可以作为一组数据的唯一摘要。同时我们可以基于Merkle Tree,通过提供某一数据的Merkle分支路径来实现对该数据的存在性验证,该证明即为Merkle证明。From the construction process of Merkle Tree, we can find that the data recorded by any leaf node is modified, and the hash value of the leaf node will change accordingly, which will eventually affect the hash value of the root node. Therefore, the hash value of the root node can be used as the only summary of a set of data. At the same time, we can verify the existence of a certain data by providing the Merkle branch path of the data based on the Merkle Tree. The proof is the Merkle proof.
如图1中,验证方若想验证D2是否存在于Merkle Tree中,则区块链节点可以提供D1-H10-H14的Merkle分支路径,验证方根据该分支路径,算出D1和D2的哈希值,然后将H1和H2求哈希值,再与H10求哈希值,最后与H14求哈希值,得到的哈希值如果与根节点记录的哈希值一致,则表示D2存在于Merkle Tree中。As shown in Figure 1, if the verifier wants to verify whether D2 exists in the Merkle Tree, the blockchain node can provide the Merkle branch path of D1-H10-H14, and the verifier calculates the hash values of D1 and D2 according to the branch path , Then calculate the hash value of H1 and H2, then calculate the hash value with H10, and finally calculate the hash value with H14. If the obtained hash value is consistent with the hash value recorded by the root node, it means that D2 exists in Merkle Tree in.
2、Trie Tree(前缀树)2. Trie Tree (prefix tree)
Trie Tree是一种搜索树,又称Digital Tree(字典树)。与二叉树不同,Trie Tree的键值并不是由树中的节点存储,而是取决于其在树中的位置(即从根节点到达特定节点的路径)。一个节点的所有子孙都有相同的前缀,为这个节点对应的字符串(根节点对应空字符串)。只有叶子节点才有对应的存储数值。Trie Tree is a search tree, also known as Digital Tree (dictionary tree). Unlike a binary tree, the key value of a Trie Tree is not stored by the nodes in the tree, but depends on its position in the tree (that is, the path from the root node to a specific node). All descendants of a node have the same prefix, which is the string corresponding to this node (the root node corresponds to an empty string). Only leaf nodes have corresponding storage values.
3、Patricia Tree(压缩前缀树)3. Patricia Tree (compressed prefix tree)
Patricia Tree是一种更节省空间的前缀树,一个节点如果没有兄弟节点,则与其父节点合并。Patricia Tree is a more space-saving prefix tree. If a node has no sibling nodes, it is merged with its parent node.
4、以太坊的状态树和存储树4. Ethereum's state tree and storage tree
如图2所示,以太坊包括状态树和存储树,状态树可以是状态MPT(可以认为MPT=Merkle Tree+Patricia Tree)或状态Merkle Tree,存储树可以是存储MPT或存储Merkle Tree。As shown in Figure 2, Ethereum includes a state tree and a storage tree. The state tree can be a state MPT (can be considered MPT=Merkle Tree+Patricia Tree) or a state Merkle Tree, and the storage tree can be a storage MPT or a storage Merkle Tree.
状态树由以太坊的账户构成,状态树的根节点的哈希记录在每个区块头的状态树根(state root)字段中。存储树是保存与账户相关联数据的结构,该项只有合约账户才有,所有智能合约的数据都以32字节映射的形式保存在存储树中。存储树的根节点的哈希值记录在账户的storage root字段中。The state tree is composed of Ethereum accounts, and the hash of the root node of the state tree is recorded in the state root field of each block header. The storage tree is a structure for storing data associated with an account. This item is only available for contract accounts. All smart contract data is stored in the storage tree in the form of a 32-byte mapping. The hash value of the root node of the storage tree is recorded in the storage root field of the account.
状态MPT或存储MPT的叶子节点记录key-value数据项的value,其key编码由MPT的从根节点到达叶子节点的路径构成。The state MPT or the leaf node storing the MPT records the value of the key-value data item, and the key code is composed of the path from the root node to the leaf node of the MPT.
以太坊的状态树和存储树中,仍然可以基于Merkle证明对账户数据(包括账户状态和 合约状态)进行存在性验证,以图2为例,若要验证合约状态之一的27在区块60中的存在性,则需要在存储树中确定用于验证27的分支路径,并根据该分支路径验证27是否构成Account 175的存储树,同时也需要在状态树中确定用于验证Account 175的分支路径,并根据该分支路径验证Account 175是否构成区块59的状态树,即需要进行两次Merkle证明。In the state tree and storage tree of Ethereum, the existence of account data (including account state and contract state) can still be verified based on Merkle proof. Take Figure 2 as an example, if you want to verify that one of the contract states 27 is in block 60 If the existence of, you need to determine the branch path used to verify 27 in the storage tree, and verify whether 27 constitutes the storage tree of Account 175 according to the branch path, and also need to determine the branch used to verify Account 175 in the state tree According to the branch path, it is verified whether Account 175 constitutes the state tree of block 59, that is, two Merkle proofs are required.
但随着区块链数据的不断增长,需在链上分配更多的额外空间来存储树的构建关系。另外,链上数据的增加也使得提供分支路径以及外部进行Merkle证明的耗时也会越来越大。However, with the continuous growth of blockchain data, more additional space needs to be allocated on the chain to store the relationship of the tree construction. In addition, the increase in data on the chain also makes it more and more time-consuming to provide branch paths and perform external Merkle proofs.
为解决上述问题,本发明实施例提供一种新的状态树和存储树的构建关系,其中,状态树和存储树中仅用于存储当前区块交易执行过程中所修改的账户数据,如新增的账户数据或被修改的账户数据。本发明实施例提供一种状态树和存储树可以如图3所示,对比于图2解释如下:In order to solve the above problems, the embodiments of the present invention provide a new construction relationship between the state tree and the storage tree, wherein the state tree and the storage tree are only used to store the account data modified during the execution of the current block transaction, such as new Increased account data or modified account data. The embodiment of the present invention provides a state tree and a storage tree as shown in FIG. 3, which are explained as follows in comparison with FIG. 2:
如图2的状态树和存储树中,区块60执行过程中修改了Account 175的合约状态,27变为45,则基于原有Account 175的合约状态26和该修改后的合约状态45确定父节点中的哈希值,并将构建出的存储树的根节点哈希值存储至区块60的Account 175的storage root字段中;基于原有Account 174的账户状态和该修改后的Account 175的账户状态确定父节点中的哈希值,并将构建出的状态树的根节点哈希值存储至区块60的state root字段中。In the state tree and storage tree shown in Figure 2, the contract state of Account 175 is modified during the execution of block 60, and 27 becomes 45. The parent is determined based on the contract state 26 of the original Account 175 and the modified contract state 45. The hash value in the node, and the hash value of the root node of the constructed storage tree is stored in the storage root field of Account 175 in block 60; based on the account status of the original Account 174 and the modified Account 175 The account state determines the hash value in the parent node, and stores the hash value of the root node of the constructed state tree in the state root field of the block 60.
如图3的状态树和存储树中,区块60执行过程中修改了Account 175的合约状态,27变为45,则仅基于当前Account 175的修改后的合约状态45确定父节点中的哈希值,并将构建出的存储树的根节点哈希值存储至区块60的Account 175的storage root字段中;基于该修改后的Account 175的账户状态确定父节点中的哈希值,并将构建出的状态树的根节点哈希值存储至区块60的state root字段中。In the state tree and storage tree as shown in Figure 3, the contract state of Account 175 is modified during the execution of block 60. When 27 becomes 45, the hash in the parent node is determined only based on the modified contract state 45 of the current Account 175 The hash value of the root node of the constructed storage tree is stored in the storage root field of Account 175 of block 60; the hash value in the parent node is determined based on the account status of the modified Account 175, and the The hash value of the root node of the constructed state tree is stored in the state root field of the block 60.
由上可知,本发明实施例中的状态树和存储树仅基于当前区块交易执行过程中所修改的或新增的账户数据生成,而不会再基于原有区块对应的未发生变化的账户数据生成,该方式通过精简数据量,可以极大地减少状态树和存储树的层级。举例来说,现有技术采用10000个账户构建区块60对应的状态树,而本发明实施例中若区块60中所有交易执行后仅有1000个账户的账户数据发生变化,则本发明实施例只需要采用1000个账户构建区块60对应的状态树,且该1000个账户基于各自发生变化的合约数据构建各自的存储树,本发明实施例的数据量减少至原数据量的1/10,可以极大地减少状态树和存储树的层级。It can be seen from the above that the state tree and the storage tree in the embodiment of the present invention are only generated based on the modified or newly added account data during the transaction execution of the current block, and will not be based on the unchanged data corresponding to the original block. Account data generation. This method can greatly reduce the level of the state tree and storage tree by streamlining the amount of data. For example, the prior art uses 10,000 accounts to construct the state tree corresponding to the block 60, and in the embodiment of the present invention, if only the account data of the 1,000 accounts change after all transactions in the block 60 are executed, the present invention is implemented For example, only 1000 accounts need to be used to construct the state tree corresponding to block 60, and the 1000 accounts build their own storage trees based on the contract data that have changed. The data amount in the embodiment of the present invention is reduced to 1/10 of the original data amount. , Can greatly reduce the level of the state tree and storage tree.
此外,以太坊的状态树和存储树中,采用两次Merkle证明,先证明合约状态在存储树中,再证明账户状态在状态树中,本发明实施例可以将状态树和存储树合并为一棵树,将状态树的叶子节点中的值下移至与存储树的叶子节点中的值平级,从而扁平化账户数据的层级结构。本发明实施例提供一种新的状态树可以如图4所示。区块对应一个状态树,该状态树的叶子节点包括账户状态和合约状态,通过该方式仅需要一次Merkle证明即可以实现对账户数据的存在性验证,比如需要验证合约状态27在区块60中的存在性,则需要在该状态树中获取用于验证该27的分支路径,并根据该分支路径验证27是否构成区块60的状态树即可,相比于现有技术,状态树的层级变小,且加快了分支路径的构建及验证效率。In addition, in the state tree and storage tree of Ethereum, two Merkle proofs are used to prove that the contract state is in the storage tree, and then the account state is in the state tree. The embodiment of the present invention can merge the state tree and the storage tree into one. A tree moves the value in the leaf node of the state tree down to the same level as the value in the leaf node of the storage tree, thereby flattening the hierarchical structure of the account data. The embodiment of the present invention provides a new state tree as shown in FIG. 4. A block corresponds to a state tree. The leaf nodes of the state tree include account state and contract state. In this way, only one Merkle proof is needed to verify the existence of account data. For example, it is necessary to verify that the contract state 27 is in block 60. For the existence of the state tree, it is necessary to obtain the branch path used to verify the 27 in the state tree, and verify whether 27 constitutes the state tree of the block 60 according to the branch path. Compared with the prior art, the level of the state tree It becomes smaller and speeds up the construction and verification efficiency of branch paths.
本发明实施例中,可以将落盘存储所用的key定义为“账号标识+账户数据标识+写入/修改该key-value所在块高”,value值即为账户数据标识对应的账户数据,此外,上述key 中,账号标识可以理解成账号地址;账户数据标识可以理解成需持久化存储数据的序号,或者需持久化存储数据的标识,比如账户数据是账户状态中的账户余额,则账户数据标识可以是“balance”,比如账户数据是合约状态中的值,则账户数据标识可以是设定的序号,如图4中合约状态27的标识是2。本发明实施例中的叶子节点存储的是账户数据的哈希值。In the embodiment of the present invention, the key used for disk placement storage can be defined as "account ID + account data ID + write/modify the block height of the key-value", and the value value is the account data corresponding to the account data ID. In addition, In the above key, the account identification can be understood as the account address; the account data identification can be understood as the serial number of the data that needs to be stored persistently, or the identification of the data that needs to be stored persistently, for example, the account data is the account balance in the account status, then the account data The identifier can be "balance". For example, the account data is the value in the contract status, and the account data identifier can be a set serial number. The identifier of the contract status 27 in FIG. 4 is 2. The leaf node in the embodiment of the present invention stores the hash value of the account data.
基于key-value构建状态树,可以是构建状态MPT,key值指示MPT中从根节点到达叶子节点的路径,如图4中,key(0x234_balance_60)=100。Building a state tree based on key-value can be a state MPT. The key value indicates the path from the root node to the leaf node in the MPT, as shown in Figure 4, key(0x234_balance_60)=100.
考虑到本发明实施例所构建的状态树仅是基于变化账户的变化账户数据构建的,该构建方式存在一个问题,即不能证明一个不存在的数据的正确性,相当于无法证明一个没有构成某一区块的状态树的账户数据是否在该区块的状态树中存在。举例来说,当前区块链的块高为100,存在某个账户的账户数据只在块高20时变化过,则仅能基于块高20的区块的状态树验证该账户的账户数据的正确性,而不能基于块高20以后的任一个的区块的状态树验证该账户的账户数据的正确性。Considering that the state tree constructed in the embodiment of the present invention is only constructed based on the change account data of the change account, there is a problem with this construction method, that is, the correctness of a non-existent data cannot be proved, which is equivalent to the inability to prove that a non-existent data is not constituted Whether the account data of the state tree of a block exists in the state tree of the block. For example, if the block height of the current blockchain is 100, there is an account whose account data has only changed when the block height is 20, and the account data of the account can only be verified based on the state tree of the block height of 20 The correctness of the account data cannot be verified based on the state tree of any block after the block height is 20.
为了解决上述问题,本发明实施例在存储上述key-value键值对的基础上,还会增加另外一组key-value键值对,其中,该key中包括账户标识和账户数据标识,此时的账户数据标识对应块高记录,value值即为块高记录,该块高记录用于记录账户标识对应账户中的账户数据发生历次变化时所在的区块的块高。In order to solve the above-mentioned problem, the embodiment of the present invention will add another set of key-value key-value pairs based on storing the above-mentioned key-value key-value pairs, where the key includes an account identifier and an account data identifier. The account data identifier corresponds to the block height record, and the value value is the block height record. The block height record is used to record the block height of the block where the account data in the account corresponding to the account identifier has been changed.
举例来说,如图4中,区块链的当前区块高度为60,0x234_1为持久化存储的key,1为块高记录的标识,12-45-50为记录的块高记录,可以理解为账户0x234在区块高度12写入,在区块高度45和50进行修改。当前区块链上存储如表1所示的四个key-value键值对,其中,第一个key-value键值对即指示该账户0x234的块高记录,第二个至第四个key-value键值对即指示该账户0x234在对应块高上写入或修改时的balance值。For example, as shown in Figure 4, the current block height of the blockchain is 60, 0x234_1 is the key of persistent storage, 1 is the identifier of the block height record, and 12-45-50 is the block height record of the record. It is understandable For account 0x234, write at block height 12 and modify at block heights 45 and 50. The current blockchain stores four key-value key-value pairs as shown in Table 1. Among them, the first key-value key-value pair indicates the block height record of the account 0x234, and the second to fourth keys The -value key-value pair indicates the balance value of the account 0x234 when writing or modifying the corresponding block height.
表1Table 1
keykey valuevalue
0x234_10x234_1 12-45-5012-45-50
0x234_balance_12 0x234_balance_12 100100
0x234_balance_450x234_balance_45 300300
0x234_balance_500x234_balance_50 200200
通过存储该key-value键值对,可以快速确定出账户所对应的账户数据发生历次变化时所在的区块的块高,进一步确定应该基于哪一个区块的状态树验证待验证数据的正确性,具体实现方式可在下面具体描述。By storing the key-value key-value pair, it is possible to quickly determine the block height of the block where the account data corresponding to the account has undergone previous changes, and further determine which block's state tree should be used to verify the correctness of the data to be verified , The specific implementation can be described in detail below.
基于上述描述,图5示例性的示出了本发明实施例提供的一种区块的状态树的生成方法的流程,该流程可以由区块的状态树的生成的装置执行,该装置可以位于区块链节点中,可以是该区块链节点。Based on the above description, FIG. 5 exemplarily shows the flow of a method for generating a state tree of a block provided by an embodiment of the present invention. The flow may be executed by a device for generating a state tree of a block, and the device may be located in Among the blockchain nodes, it can be the blockchain node.
步骤501,区块链节点针对区块链中的任一区块,确定区块的第一账户和第一账户数据。In step 501, the blockchain node determines the first account and first account data of the block for any block in the blockchain.
其中,第一账户是区块中各交易执行后账户数据发生变化的账户,第一账户数据是各交易执行后第一账户中发生变化后的账户数据。Among them, the first account is the account whose account data changes after the execution of each transaction in the block, and the first account data is the account data after the change in the first account after the execution of each transaction.
具体实现中,区块链节点基于当前区块中的各交易,确定各交易所涉及的账户,且判断各交易所涉及的账户中的账户数据是否发生变化,账户数据发生变化的账户即为第一账 户,发生变化的账户数据即为第一账户数据,一个第一账户中可能存在一个第一账户数据,也可能存在多个第一账户数据。In specific implementation, the blockchain node determines the account involved in each transaction based on each transaction in the current block, and judges whether the account data in the account involved in each transaction has changed, and the account whose account data has changed is the first account. For an account, the changed account data is the first account data. There may be one first account data in a first account, or there may be multiple first account data.
可选的,第一账户中可能存在的第一账户数据可以包括各交易执行后第一账户中发生变化的块高记录、账户状态和/或合约状态。如表1中的例子,在区块50的第一账户0x234中可以包括的第一账户数据有块高记录12-45-50和balance的值200。Optionally, the first account data that may exist in the first account may include block height records, account status, and/or contract status that have changed in the first account after each transaction is executed. As in the example in Table 1, the first account data that can be included in the first account 0x234 of the block 50 has a block height record of 12-45-50 and a balance value of 200.
又例如,当前区块中各交易共涉及账户100个,账户数据发生变化的账户为98个,则此时该当前区块对应的第一账户即为98个,该98个账户中的每一个账户都对应至少一个发生变化的账户数据。此处,可以是当前区块中的一笔交易或者多笔交易导致某个账户的状态数据在当前区块执行完毕后状态数据不发生变化。For another example, each transaction in the current block involves a total of 100 accounts, and the number of accounts whose account data has changed is 98. At this time, the first account corresponding to the current block is 98, and each of the 98 accounts Each account corresponds to at least one account data that has changed. Here, it may be that one transaction or multiple transactions in the current block cause the status data of a certain account to not change after the current block is executed.
步骤502,区块链节点构建由各第一账户和各第一账户的第一账户数据构成的区块的状态树,并将状态树的根哈希存储在区块的区块头中。In step 502, the blockchain node constructs a state tree of the block composed of each first account and the first account data of each first account, and stores the root hash of the state tree in the block header of the block.
其中,状态树以键值对的方式存储。Among them, the state tree is stored in the form of key-value pairs.
在构建过程中,可以针对任一第一账户的任一第一账户数据,将第一账户的标识、第一账户数据的标识和区块的块高作为key值,第一账户数据作为叶子节点的value值,基于MPT模式构建区块的状态树。In the construction process, for any first account data of any first account, the identification of the first account, the identification of the first account data, and the block height of the block can be used as the key value, and the first account data can be used as the leaf node The value value of the block is based on the MPT mode to build the state tree of the block.
本发明实施例中,直接将key值进行持久化存储,而不是将key值的哈希进行持久化存储,通过该方式,可以保障同一账户下的账户数据具有相同的压缩前缀,也就是账号标识或账户地址,如图4所示,0x234的所有账户数据的key都有相同的前缀,即0x234,所以至少可以将0x234的所有账户数据的key以共同前缀0x234进行压缩。而现有技术中,对0x234的所有账户数据的key进行哈希计算后,所存在的共同前缀变少,形成状态树的层级较深。所以,本发明实施例可以有效利用Patricia Tree的优势,将状态树的层级压缩至最小,减少存储空间的同时也加快了分支路径的构建及验证效率。In the embodiment of the present invention, the key value is directly stored persistently instead of the hash of the key value. In this way, it can be ensured that the account data under the same account have the same compressed prefix, that is, the account identifier. Or the account address, as shown in Figure 4, all the keys of the account data of 0x234 have the same prefix, that is, 0x234, so at least the keys of all the account data of 0x234 can be compressed with the common prefix 0x234. In the prior art, after hashing the keys of all account data of 0x234, there are fewer common prefixes, and the level of the state tree is deeper. Therefore, the embodiment of the present invention can effectively utilize the advantages of Patricia Tree, compress the level of the state tree to a minimum, reduce storage space, and speed up the construction and verification efficiency of branch paths.
基于上述区块链节点中状态树的构建方案,本发明实施例还提供一种链上数据验证的方法,该方法适用于如图6所示的系统架构,该系统架构可以包括客户端和区块链节点。其中,客户端又可以理解成数据使用方,区块链节点又可以理解成数据提供方;区块链节点是客户端可以访问的区块链系统中的任一个区块链节点。Based on the above-mentioned construction scheme of the state tree in the blockchain node, the embodiment of the present invention also provides a method for on-chain data verification. The method is suitable for the system architecture shown in FIG. 6, and the system architecture may include a client and a zone. Block chain node. Among them, the client can be understood as the data user, and the blockchain node can be understood as the data provider; the blockchain node is any blockchain node in the blockchain system that the client can access.
如图7为本发明实施例示出的链上数据验证的方法的流程,该流程具体包括:Fig. 7 is the flow of the method for on-chain data verification shown in the embodiment of the present invention, and the flow specifically includes:
步骤701,客户端向区块链节点发送数据获取请求。Step 701: The client sends a data acquisition request to the blockchain node.
数据获取请求包括第二账户的标识、第二账户数据的标识和第一块高,该数据获取请求用于指示获取第二账户的第二账户数据在第一块高上的值。The data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height, and the data acquisition request is used to instruct to acquire the value of the second account data of the second account on the first block height.
步骤702,区块链节点根据第二账户的标识和第二账户的第一块高记录的标识,确定第一块高记录。Step 702: The blockchain node determines the first high record according to the identifier of the second account and the identifier of the first high record of the second account.
区块链节点接收客户端发送的数据获取请求后,会根据第二账户的标识和第二账户的第一块高记录的标识,确定第一块高记录,如表1中,第二账户的标识为0x234,第二账户的第一块高记录的标识为1,则组成的key为0x234_1,根据持久化存储的key-value键值对,确定key为0x234_1对应的value为12-45-50。After the blockchain node receives the data acquisition request sent by the client, it will determine the first high record according to the identification of the second account and the identification of the first high record of the second account, as shown in Table 1, the second account The ID is 0x234, and the ID of the first high record of the second account is 1, then the composed key is 0x234_1. According to the key-value key-value pair in the persistent storage, the value corresponding to the key 0x234_1 is determined to be 12-45-50 .
步骤703,区块链节点根据第二账户的标识、第二账户数据的标识、第一块高,确定第二账户数据。Step 703: The blockchain node determines the second account data according to the identification of the second account, the identification of the second account data, and the height of the first block.
区块链节点根据第二账户的标识、第二账户数据的标识、第一块高,确定第二账户数据,如表1中,若第一块高为48,则确定第二账户的标识为0x234,第二账户数据的标识 为balance,则组成的key为0x234_balance_45,根据持久化存储的key-value键值对,确定key为0x234_balance_45对应的value为300。The blockchain node determines the second account data according to the identification of the second account, the identification of the second account data, and the height of the first block. As shown in Table 1, if the height of the first block is 48, the identification of the second account is determined to be 0x234, the identifier of the second account data is balance, and the composed key is 0x234_balance_45. According to the key-value key-value pair in the persistent storage, the value corresponding to the key 0x234_balance_45 is determined to be 300.
步骤704,区块链节点从第一区块的状态树中获取用于验证第一块高记录的第一分支路径。In step 704, the blockchain node obtains the first branch path for verifying the high record of the first block from the state tree of the first block.
步骤705,区块链节点从第二区块的状态树中获取用于验证第二账户数据的第二分支路径。Step 705: The blockchain node obtains the second branch path for verifying the second account data from the state tree of the second block.
由于发明实施例中构建某个区块的状态树只能用于验证该区块的状态树对应的账户数据的存在性,所以,要验证第二账户数据的存在性,需要先确定第二账户数据所在状态树对应的第二区块,进而根据第二区块的状态树,确定用于验证第二账户数据的第二分支路径。Since the state tree of a certain block constructed in the embodiment of the invention can only be used to verify the existence of the account data corresponding to the state tree of the block, to verify the existence of the second account data, the second account needs to be determined first The second block corresponding to the state tree where the data is located, and then according to the state tree of the second block, determine the second branch path for verifying the second account data.
在确定第二账户数据所在状态树对应的第二区块时,需要先确定该第二账户的账户数据历次被修改时所记录的块高记录,也即需要确定出第一块高记录,在确定出第一块高记录后,可以将第一块高记录中低于第一块高的所有块高中的最高的块高所对应的区块作为第二区块,该第二区块即用于记录第二账户在第一块高之前的最近一次被修改后的账户数据,进而根据第二区块的状态树,确定用于验证第二账户数据的第二分支路径。When determining the second block corresponding to the state tree where the second account data is located, it is necessary to determine the block height record recorded when the account data of the second account has been previously modified, that is, the first block height record needs to be determined. After the first block height record is determined, the block corresponding to the highest block height of all block heights lower than the first block height in the first block height record can be used as the second block, and the second block is ready to use After recording the last modified account data of the second account before the first block height, the second branch path for verifying the second account data is determined according to the state tree of the second block.
此外,为了保障第一块高记录的正确性,同样需要确定第一块高记录所在的状态树对应的第一区块,进而根据第一区块的状态树,确定用于验证第一块高记录的第一分支路径。具体的,该第一区块可以是第一块高记录中最高块高对应的区块。In addition, in order to ensure the correctness of the first block of high records, it is also necessary to determine the first block corresponding to the state tree where the first block of high records is located, and then determine the first block to verify the first block according to the state tree The first branch path recorded. Specifically, the first block may be the block corresponding to the highest block height in the first block height record.
如表1中,若第一块高为48,则第一分支路径是由块高50的第一区块对应的状态树确定的,第二分支路径是由块高45的第二区块对应的状态树确定的。As shown in Table 1, if the first block height is 48, the first branch path is determined by the state tree corresponding to the first block of block height 50, and the second branch path is corresponding to the second block of block height 45 The state tree is determined.
步骤706,区块链节点将第一块高记录、第一分支路径、第二账户数据、第二分支路径发送至客户端。In step 706, the blockchain node sends the first high record, the first branch path, the second account data, and the second branch path to the client.
步骤707,客户端根据第一分支路径、本地存储的第一区块的区块头中状态树的根哈希验证第一块高记录是否正确;Step 707: The client verifies whether the first block of high records is correct according to the first branch path and the root hash of the state tree in the block header of the first block stored locally;
客户端本地存储有区块链上各区块的区块头,用于在接收到区块链节点发送的第一块高记录、第一分支路径、第二账户数据、第二分支路径后,分别根据对应的区块头中的信息,对第一块高记录和第二账户数据进行验证。The client locally stores the block headers of each block on the blockchain, which are used for receiving the first high record, the first branch path, the second account data, and the second branch path sent by the blockchain node. The information in the corresponding block header verifies the first high record and the second account data.
一种实现方式下,可以是客户端定时去区块链节点获取最新区块的区块头,另一实现方式下,可以是客户端在需要对接收到的数据进行验证时,再去区块链节点上获取。前者具体可以如图8所示,由客户端和区块链节点交互完成。In one implementation method, the client can periodically go to the blockchain node to obtain the block header of the latest block. In another implementation method, the client can go to the blockchain when it needs to verify the received data. Get it on the node. The former can be specifically shown in Figure 8 and completed by the interaction between the client and the blockchain node.
步骤801,客户端向区块链节点发送查询请求;Step 801, the client sends a query request to the blockchain node;
步骤802,区块链节点向客户端发送区块链的当前块高;Step 802, the blockchain node sends the current block height of the blockchain to the client;
步骤803,客户端确定本地存储的区块头的最高块高小于当前块高;Step 803: The client determines that the highest block height of the locally stored block header is smaller than the current block height;
步骤804,客户端向区块链节点发送区块头获取请求;Step 804, the client sends a block header acquisition request to the blockchain node;
步骤805,区块链节点确定客户端待获取的区块头;Step 805, the blockchain node determines the block header to be obtained by the client;
步骤806,区块链节点向客户端发送待获取的区块头;Step 806, the blockchain node sends the block header to be obtained to the client;
步骤807,客户端接收区块链节点返回的区块头,将接收到的区块头存储在本地。In step 807, the client receives the block header returned by the blockchain node, and stores the received block header locally.
步骤801至步骤807中,客户端向区块链节点发送查询请求,区块链节点在接收到该查询请求后,会向客户端反馈当前区块链上的当前块高,客户端接收该包括当前块高的查询结果,用于根据查询结果判断是否需要向区块链节点同步区块头,具体的,客户端判断 本地存储的区块头的最高块高是否小于区块链上的当前块高,若是,则确定向区块链节点同步区块头,并向区块链节点发送区块头获取请求,其中,该区块头获取请求中即包括待获取区块头的块高。In step 801 to step 807, the client sends a query request to the blockchain node. After receiving the query request, the blockchain node will feedback the current block height on the current blockchain to the client, and the client will receive the query request. The query result of the current block height is used to determine whether the block header needs to be synchronized with the blockchain node according to the query result. Specifically, the client determines whether the highest block height of the locally stored block header is less than the current block height on the blockchain. If it is, it is determined to synchronize the block header to the blockchain node, and send a block header acquisition request to the blockchain node, where the block header acquisition request includes the block height of the block header to be acquired.
举个例子,区块链节点的区块链的当前块高为100,客户端本地存储的区块头的最高块高为98,则客户端确定需要向区块链节点获取第99个、第100个区块的区块头,客户端向区块链节点发送区块头获取请求,其中,该区块头获取请求中即包括待获取区块头的块高为99和100。For example, if the current block height of the blockchain of the blockchain node is 100, and the highest block height of the block header stored locally by the client is 98, the client determines that it needs to obtain the 99th and 100th from the blockchain node. For the block header of each block, the client sends a block header acquisition request to the blockchain node, where the block header acquisition request includes the block heights of the block header to be acquired as 99 and 100.
上述实现方式中,客户端定时去区块链节点获取最新区块的区块头,可以保障在需要对账户数据进行验证时,本地存储有用于验证的区块的区块头信息。In the foregoing implementation manner, the client regularly goes to the blockchain node to obtain the block header of the latest block, which can ensure that when the account data needs to be verified, the block header information of the block used for verification is stored locally.
由上可知,客户端可以根据第一分支路径、本地存储的第一区块的区块头中状态树的根哈希,确定第一块高记录是否正确。此处,客户端本地存储的第一区块也即客户端从区块链节点上获取的第一块高记录中的最高块高对应的区块。It can be seen from the above that the client can determine whether the first block high record is correct according to the first branch path and the root hash of the state tree in the block header of the first block stored locally. Here, the first block stored locally by the client is the block corresponding to the highest block height in the first block height record obtained by the client from the blockchain node.
具体验证过程中,客户端根据第一块高记录和第一分支路径中叶子节点和分支节点的数据,确定第一根哈希,若客户端确定第一根哈希等于本地存储的第一区块的区块头中状态树的根哈希,则确定第一块高记录正确。In the specific verification process, the client determines the first root hash according to the first block of high records and the data of the leaf nodes and branch nodes in the first branch path. If the client determines that the first root hash is equal to the first area stored locally The root hash of the state tree in the block header of the block determines that the first block high record is correct.
步骤708,客户端在确定第一块高记录正确之后,根据第二分支路径、本地存储的第二区块的区块头中状态树的根哈希,验证第二账户数据的是否正确。Step 708: After determining that the first block of high records is correct, the client verifies whether the second account data is correct according to the second branch path and the root hash of the state tree in the block header of the second block stored locally.
客户端先判断第一块高记录是否正确,若正确之后,则可以进一步根据第二分支路径、本地存储的第二区块的区块头中状态树的根哈希,验证第二账户数据的正确性,其中,客户端本地存储的第二区块的区块头是从区块链节点上获取的,第二区块是区块链上第二块高对应的区块,第二块高是第一块高记录中低于第一块高的所有块高中的最高的块高。The client first judges whether the first high record is correct. If it is correct, it can further verify the correctness of the second account data based on the second branch path and the root hash of the state tree in the block header of the second block stored locally. The block header of the second block stored locally by the client is obtained from the blockchain node, the second block is the block corresponding to the second block on the blockchain, and the second block is the first block. The highest block height of all block highs in a block high record lower than the first block height.
具体验证过程中,客户端可以根据第二账户数据和第二分支路径中叶子节点和分支节点的数据,确定第二根哈希,若客户端确定第二根哈希等于本地存储的第二区块的区块头中状态树的根哈希,则确定第二账户数据正确。During the specific verification process, the client can determine the second root hash according to the second account data and the data of the leaf nodes and branch nodes in the second branch path. If the client determines that the second root hash is equal to the second area stored locally The root hash of the state tree in the block header of the block determines that the second account data is correct.
需要说明的是,本发明实施例中虽然提供的是客户端先获取第一块高记录和第二账户数据,并基于第一区块对第一块高记录进行验证以及基于第二区块对第二账户数据进行验证,但本发明实施例中还可以是客户端先获取第一块高记录,并基于第一区块对第一块高记录进行验证,在对第一块高记录进行验证通过后,进而获取第二账户数据,并基于第二区块对第二账户数据进行验证。It should be noted that, although it is provided in the embodiment of the present invention that the client first obtains the first block of high records and the second account data, and verifies the first block of high records based on the first block, and based on the second block pair The second account data is verified, but in the embodiment of the present invention, the client may first obtain the first block of high records, and verify the first block of high records based on the first block, and then verify the first block of high records. After passing, the second account data is obtained, and the second account data is verified based on the second block.
需要说明的是,由于客户端基于本地存储的第一区块的区块头的状态树的根哈希对第一块高记录进行验证,以及基于本地存储的第二区块的区块头的状态树的根哈希对第二账户数据进行验证,所以客户端首先需要确定本地存储的区块头信息是正确的。It should be noted that the client verifies the first block of high records based on the root hash of the state tree of the block header of the first block stored locally, and the state tree based on the block header of the second block stored locally The root hash of to verify the data of the second account, so the client first needs to make sure that the locally stored block header information is correct.
为证明区块头中信息的正确性,具体实现中,在区块头中增加了链上节点对区块头的签名列表,客户端在获取到该区块头后,会根据区块头中的签名列表验证该区块头的正确性,具体的,客户端将接收到的区块头存储在本地之前,获取接收到的区块头中的N个签名信息,并根据本地共识节点列表,对N个签名信息验证,若N个签名信息通过验证,则确定接收到的区块头正确。此处,共识节点列表是客户端根据区块链的创世块中的区块头至接收到的区块头的前一个区块头确定的共识节点组成的列表,如客户端获取到的当前的区块头是第100个区块的区块头,则客户端需要根据第0个区块(创世块)至第99个区块的区块头确定的共识节点列表,对当前的区块头的签名信息进行验证。In order to prove the correctness of the information in the block header, in the specific implementation, the signature list of the node on the chain is added to the block header. After obtaining the block header, the client will verify the block header according to the signature list in the block header. The correctness of the block header, specifically, before storing the received block header locally, the client obtains the N signature information in the received block header, and verifies the N signature information according to the local consensus node list. If If the N signature information is verified, it is determined that the received block header is correct. Here, the consensus node list is a list of consensus nodes determined by the client according to the block header in the genesis block of the blockchain to the previous block header of the received block header, such as the current block header obtained by the client Is the block header of the 100th block, the client needs to verify the signature information of the current block header based on the consensus node list determined by the block headers of the 0th block (the genesis block) to the 99th block .
解释为,共识节点列表中的共识节点是在区块链的创世块中确定的,在后续区块交易中可能发生改变,比如,创世块中确定共识节点列表中的共识节点有A、B、C、D;在第0个区块至第49个区块时,区块头中共识节点列表中的共识节点未发生变化;在第50个区块时,区块中的交易执行后共识节点列表中增加共识节点E,则此时,共识节点列表中的共识节点有A、B、C、D、E;在第50个区块至第99个区块时共识节点列表中的共识节点未发生变化;所以,客户端在验证第100个区块头中N个签名信息时,可以是根据第0个区块至第99个区块的区块头确定的共识节点列表对该N个签名信息进行验证。The explanation is that the consensus nodes in the consensus node list are determined in the genesis block of the blockchain, and may change in subsequent block transactions. For example, the consensus nodes in the consensus node list in the genesis block have A, B, C, D; from the 0th block to the 49th block, the consensus node in the consensus node list in the block header has not changed; at the 50th block, the consensus after the transaction in the block is executed Consensus node E is added to the node list. At this time, the consensus nodes in the consensus node list are A, B, C, D, E; the consensus node in the consensus node list from the 50th block to the 99th block No change has occurred; therefore, when the client verifies the N signature information in the 100th block header, it can be based on the consensus node list determined from the 0th block to the 99th block. authenticating.
上述实施例中,虽然说共识节点列表是根据第0个区块至第99个区块的区块头确定的,但是在对第100个区块的区块头中签名信息进行验证时,直接采用第99个区块的区块头中共识节点列表进行验证即可,因为第99个区块的区块头已经通过第98个区块的区块头中共识节点列表的验证,第98个区块的区块头已经通过第97个区块的区块头中共识节点列表的验证,以此类推,第2个区块的区块头已经通过第1个区块的区块头中共识节点列表的验证,第1个区块的区块头已经通过第0个区块的区块头中共识节点列表的验证。In the above embodiment, although the consensus node list is determined based on the block headers of the 0th block to the 99th block, when verifying the signature information in the block header of the 100th block, the first block is directly used. The list of consensus nodes in the block header of 99 blocks can be verified, because the block header of the 99th block has passed the verification of the consensus node list in the block header of the 98th block, and the block header of the 98th block Has passed the verification of the consensus node list in the block header of the 97th block, and so on, the block header of the second block has passed the verification of the consensus node list in the block header of the first block, the first block The block header of the block has passed the verification of the consensus node list in the block header of the 0th block.
此外,在当前区块的交易执行后共识节点列表中共识节点发生变化,则相当于某个合约数据发生变化,则需要采用当前区块的区块头的状态树根哈希验证该合约数据的正确性,以及采用当前区块的前一个区块的区块头的共识节点列表验证该当前区块头中的签名信息,相当于采用当前区块的前一个区块的区块头的共识节点列表验证该当前区块的区块头中状态树根哈希的正确性。仍以上述例子说明,第50个区块中的交易执行后共识节点列表中增加共识节点E,则第50个区块对应的状态树的合约数据发生变化,如增加某个合约数据(代表共识节点E),则需要采用第50个区块中状态树的根哈希对该增加的合约数据进行存在性验证,以及采用第49个区块的共识节点列表对该第50个区块的区块头信息进行验证,即对该第50个区块的区块头中状态树的根哈希进行验证。In addition, after the transaction of the current block is executed, the consensus node in the consensus node list changes, which is equivalent to a change in a certain contract data, and the state tree root hash of the block header of the current block needs to be used to verify the correctness of the contract data And using the consensus node list of the block header of the previous block of the current block to verify the signature information in the current block header is equivalent to using the consensus node list of the block header of the previous block of the current block to verify the current block The correctness of the root hash of the state tree in the block header of the block. Still taking the above example to illustrate, if the consensus node E is added to the consensus node list after the transaction in the 50th block is executed, the contract data of the state tree corresponding to the 50th block will change, such as adding a certain contract data (representing consensus Node E), it is necessary to use the root hash of the state tree in the 50th block to verify the existence of the added contract data, and to use the consensus node list of the 49th block for the 50th block. The block header information is verified, that is, the root hash of the state tree in the block header of the 50th block is verified.
具体验证过程中,可以是客户端确定N个签名信息对应的N个共识节点,并判断N个共识节点中在共识节点列表中的M个共识节点,若M符合预设条件,则确定N个签名信息通过验证。M符合预设条件,指的是M的个数符合预设阈值,在不同共识算法情况下,预设阈值可以取不同值。一种实现方式中,采用PBFT(Practical Byzantine Fault Tolerance,实用拜占庭容错)共识算法,则预设阈值为f+1,当共识节点个数大于等于f+1时,即代表该区块的块头信息通过验证,其中,f=(N-1)/3。另一种实现方式中,采用POW(Proof of Work,工作证明)共识算法,则预设阈值为N/2+1,当共识节点个数大于等于N/2+1时,即代表该区块的块头信息通过验证,其中,N为共识列表中共识节点的个数。In the specific verification process, the client can determine the N consensus nodes corresponding to the N signature information, and determine the M consensus nodes in the consensus node list among the N consensus nodes. If M meets the preset conditions, determine N consensus nodes The signature information is verified. M meets the preset condition, which means that the number of M meets the preset threshold. In the case of different consensus algorithms, the preset threshold can take different values. In one implementation, the PBFT (Practical Byzantine Fault Tolerance) consensus algorithm is adopted, and the preset threshold is f+1. When the number of consensus nodes is greater than or equal to f+1, it represents the block header information of the block Through verification, where f=(N-1)/3. In another implementation method, the POW (Proof of Work) consensus algorithm is adopted, and the preset threshold is N/2+1. When the number of consensus nodes is greater than or equal to N/2+1, it represents the block The block header information of is verified, where N is the number of consensus nodes in the consensus list.
此外,客户端还需要验证创世块信息的正确性,当客户端验证区块链上有特定个数的共识节点的创世块信息一致,即认可该创世块。此处的特定个数可以是上述预设阈值。In addition, the client also needs to verify the correctness of the genesis block information. When the client verifies that the genesis block information of a certain number of consensus nodes on the blockchain is consistent, it recognizes the genesis block. The specific number here may be the aforementioned preset threshold.
通过上述方式,客户端从创世块开始即对创世块的块头信息进行验证,且每增加一个区块的块头,都会结合当前共识节点列表中的共识节点对当前增加的区块的块头进行验证,以保障保存至本地的区块的块头信息是正确的,从而保障用于验证账户数据的区块头中状态树的根哈希的正确性,进而实现对账户数据的验证。Through the above method, the client verifies the block header information of the genesis block from the beginning of the genesis block, and each time the block header of a block is added, the consensus node in the current consensus node list will be combined with the block header of the currently added block. Verification is to ensure that the block header information of the block saved locally is correct, so as to ensure the correctness of the root hash of the state tree in the block header used to verify the account data, and then to realize the verification of the account data.
由上可知,客户端在对某个账户数据进行验证时,验证流为创世块→共识节点→区块头信息→状态树根哈希→账户数据,也就是,创世块对共识节点验证,共识节点对区块头信息验证,区块头信息对状态树根哈希验证,状态树根哈希对账户数据验证。而且,状态树在构建时,基于哈希计算的单向性,一旦对叶子节点(账户数据)修改,则都会改变状 态树根哈希,也即,进一步保证账户数据的不被修改性。此外,上述相关验证点的信息都由链上节点提供,对于有准入概念的联盟链,链上节点在给客户端提供信息之前需进行鉴权,进一步保障数据验证的准确性。It can be seen from the above that when the client verifies certain account data, the verification flow is creation block → consensus node → block header information → state tree root hash → account data, that is, the creation block verifies the consensus node. The consensus node verifies the block header information, the block header information verifies the state tree root hash, and the state tree root hash verifies the account data. Moreover, when the state tree is constructed, based on the one-way nature of the hash calculation, once the leaf node (account data) is modified, the root hash of the state tree will be changed, that is, to further ensure that the account data is not modified. In addition, the above-mentioned relevant verification point information is provided by the nodes on the chain. For consortium chains with the concept of access, the nodes on the chain need to perform authentication before providing information to the client to further ensure the accuracy of data verification.
为了更好的解释本发明实施例,下面结合表1提供一个完整的链上数据验证的例子,具体如下:In order to better explain the embodiments of the present invention, a complete example of on-chain data verification is provided below in conjunction with Table 1. The details are as follows:
客户端向区块链节点请求获取账户0x234在块高48的区块上的balance,区块链节点先根据0x234_1确定第一块高记录12-45-50,区块链节点根据块高50的第一区块的状态树确定用于验证第一块高记录12-45-50的第一分支路径;区块链节点根据第一块高记录12-45-50和块高48,确定第一块高记录中小于块高48且最大的块高为45,区块链节点先根据0x234_balance_45确定balance为300,并根据块高45的第二区块的状态树确定用于验证balance 300的第二分支路径。区块链节点将第一块高记录12-45-50、第一分支路径和balance 300、第二分支路径一起发送至客户端,客户端根据本地存储的块高50的第一区块的区块头,结合第一分支路径验证第一块高记录12-45-50的正确性,基于已经证明的第一块高记录12-45-50,确定balance在45区块处被修改,则使用本地存储的块高45的第二区块的区块头,结合第二分支路径验证,验证balance 300的正确性。结合上述过程,客户端即完成了查询并验证账户0x234在块高48的区块上的balance为300的过程。The client requests the blockchain node to obtain the balance of the account 0x234 on the block height 48. The blockchain node first determines the first block height record 12-45-50 according to 0x234_1, and the blockchain node according to the block height 50 The state tree of the first block determines the first branch path used to verify the first block of high record 12-45-50; the blockchain node determines the first branch according to the first block of high record 12-45-50 and block height 48 The block height record is smaller than the block height 48 and the largest block height is 45. The blockchain node first determines the balance to be 300 according to 0x234_balance_45, and determines the second block used to verify the balance 300 according to the state tree of the second block with a block height of 45 Branch path. The blockchain node sends the first block of high record 12-45-50, the first branch path, balance 300, and the second branch path to the client, and the client uses the locally stored block height 50 of the first block. Block header, combined with the first branch path to verify the correctness of the first block of high record 12-45-50, based on the proven first block of high record 12-45-50, determine that the balance is modified at block 45, then use the local The stored block header of the second block with a block height of 45 is combined with the verification of the second branch path to verify the correctness of the balance 300. Combining the above process, the client has completed the process of querying and verifying that the balance of account 0x234 on the block with block height 48 is 300.
需要说明的是,图6中的客户端还可以是与区块链节点不同联盟链的区块链节点,如图9中,可以包括第一区块链节点和第二区块链节点;其中,第一区块链节点又可以理解成数据使用方,第二区块链节点又可以理解成数据提供方;第一区块链节点和第二区块链节点属于不同的联盟链。It should be noted that the client in FIG. 6 may also be a blockchain node of an alliance chain different from the blockchain node. As shown in FIG. 9, it may include a first blockchain node and a second blockchain node; where , The first blockchain node can be understood as the data user, and the second blockchain node can be understood as the data provider; the first blockchain node and the second blockchain node belong to different alliance chains.
基于同一发明构思,图10示例性的示出了本发明实施例提供的一种区块的状态树的生成装置的结构,该装置可以执行区块的状态树的生成方法的流程。Based on the same inventive concept, FIG. 10 exemplarily shows the structure of an apparatus for generating a state tree of a block provided by an embodiment of the present invention, and the apparatus can execute the flow of the method for generating a state tree of a block.
该装置包括:确定单元1001,用于针对区块链中的任一区块,确定所述区块的第一账户和第一账户数据;所述第一账户是所述区块中各交易执行后账户数据发生变化的账户,所述第一账户数据是所述各交易执行后所述第一账户中发生变化后的账户数据;构建单元1002,用于构建由各第一账户和所述各第一账户的第一账户数据构成的所述区块的状态树,并将所述状态树的根哈希存储在所述区块的区块头中,其中,所述状态树以键值对的方式存储。The device includes: a determining unit 1001 for determining a first account and first account data of the block for any block in the block chain; the first account is the execution of each transaction in the block After the account data has changed, the first account data is the account data after the change in the first account after the execution of each transaction; the construction unit 1002 is used to construct the first account and the first account. The first account data of the first account constitutes the state tree of the block, and the root hash of the state tree is stored in the block header of the block, wherein the state tree is a key-value pair Way to store.
可选的,所述构建单元1002具体用于:针对任一第一账户的任一第一账户数据,将所述第一账户的标识、所述第一账户数据的标识和所述区块的块高作为key值,所述第一账户数据作为叶子节点的value值,基于MPT模式构建所述区块的状态树。Optionally, the construction unit 1002 is specifically configured to: for any first account data of any first account, combine the identification of the first account, the identification of the first account data, and the identification of the block The block height is used as the key value, the first account data is used as the value value of the leaf node, and the state tree of the block is constructed based on the MPT mode.
可选的,所述第一账户数据包括所述各交易执行后所述第一账户中发生变化的块高记录、账户状态和/或合约状态;所述块高记录用于记录所述第一账户中的账户状态和/或合约状态发生历次变化时所在的区块的块高。Optionally, the first account data includes a block height record, an account status, and/or a contract status that have changed in the first account after the execution of each transaction; the block height record is used to record the first The block height of the block where the account status and/or contract status in the account has been changed.
可选的,所述装置还包括处理单元1003;所述处理单元1003用于:接收客户端的数据获取请求;所述数据获取请求中包括第二账户的标识、第二账户数据的标识和第一块高;根据所述第二账户的标识和所述第二账户的第一块高记录的标识,确定所述第一块高记录;根据所述第二账户的标识、所述第二账户数据的标识、所述第一块高,确定所述第二账户数据;从第一区块的状态树中获取用于验证所述第一块高记录的第一分支路径;所述第一区块是所述第一块高记录中的最高块高对应的区块;从第二区块的状态树中获取用于验证 所述第二账户数据的第二分支路径;所述第二区块是第二块高对应的区块;所述第二块高是所述第一块高记录中低于所述第一块高的所有块高中的最高的块高;将所述第一块高记录、所述第一分支路径、所述第二账户数据、所述第二分支路径发送至所述客户端,以使所述客户端对所述第一块高记录和第二账户数据进行验证。Optionally, the device further includes a processing unit 1003; the processing unit 1003 is configured to: receive a data acquisition request from the client; the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first Block height; determine the first block height record according to the identification of the second account and the identification of the first block height record of the second account; according to the identification of the second account and the second account data The identification of the first block height, the second account data is determined; the first branch path used to verify the first block height record is obtained from the state tree of the first block; the first block Is the block corresponding to the highest block height in the first block height record; the second branch path for verifying the second account data is obtained from the state tree of the second block; the second block is The block corresponding to the second block height; the second block height is the highest block height of all block heights lower than the first block height in the first block height record; the first block height is recorded , The first branch path, the second account data, and the second branch path are sent to the client, so that the client verifies the first high record and the second account data.
基于同一发明构思,图11示例性的示出了本发明实施例提供的一种链上数据验证的装置的结构,该装置可以执行链上数据验证的方法的流程。Based on the same inventive concept, FIG. 11 exemplarily shows the structure of an on-chain data verification device provided by an embodiment of the present invention, and the device can execute the flow of the on-chain data verification method.
该装置包括:收发单元1101,用于向区块链节点发送数据获取请求;所述数据获取请求包括第二账户的标识、第二账户数据的标识和第一块高;所述收发单元1101,还用于接收所述区块链节点返回的第一块高记录、第一分支路径、第二账户数据、第二分支路径;所述第一块高记录和所述第二账户数据是所述区块链节点根据所述第二账户的标识、所述第二账户数据的标识和所述第一块高确定的;所述第一分支路径是所述区块链节点确定的用于验证所述第一块高记录的分支路径;所述第二分支路径是所述区块链节点确定的用于验证所述第二账户数据的分支路径;验证单元1102,用于根据所述第一分支路径、本地存储的第一区块的区块头中状态树的根哈希验证所述第一块高记录是否正确;所述本地存储的第一区块的区块头是从所述区块链节点上获取的,所述第一区块是区块链上是所述第一块高记录中的最高块高对应的区块;所述验证单元1102,还用于在确定所述第一块高记录正确之后,根据所述第二分支路径、所述本地存储的第二区块的区块头中状态树的根哈希,验证所述第二账户数据的是否正确;所述本地存储的第二区块的区块头是从所述区块链节点上获取的,所述第二区块是所述区块链上第二块高对应的区块;所述第二块高是所述第一块高记录中低于所述第一块高的所有块高中的最高的块高。The device includes: a transceiver unit 1101, configured to send a data acquisition request to a blockchain node; the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height; the transceiver unit 1101, It is also used to receive the first block of high records, the first branch path, the second account data, and the second branch path returned by the blockchain node; the first block of high records and the second account data are the The blockchain node is determined according to the identification of the second account, the identification of the second account data, and the first block height; the first branch path is determined by the blockchain node for verification The branch path of the first block of high records; the second branch path is the branch path determined by the blockchain node for verifying the second account data; the verification unit 1102 is configured to follow the first branch Path, the root hash of the state tree in the block header of the first block stored locally to verify whether the first block high record is correct; the block header of the first block stored locally is from the blockchain node The first block is the block corresponding to the highest block height in the first block height record on the blockchain; the verification unit 1102 is also used for determining the first block height After the record is correct, verify whether the second account data is correct according to the second branch path and the root hash of the state tree in the block header of the locally stored second block; the locally stored second The block header of the block is obtained from the block chain node, the second block is the block corresponding to the second block height on the block chain; the second block height is the first block height The block height records the highest block height of all block heights lower than the first block height.
可选的,所述验证单元1102具体用于:根据所述第一块高记录和所述第一分支路径中叶子节点和分支节点的数据,确定第一根哈希;若所述第一根哈希等于所述本地存储的第一区块的区块头中状态树的根哈希,则确定所述第一块高记录正确。Optionally, the verification unit 1102 is specifically configured to: determine the first root hash according to the first block height record and the data of leaf nodes and branch nodes in the first branch path; if the first root If the hash is equal to the root hash of the state tree in the block header of the first block stored locally, it is determined that the high record of the first block is correct.
可选的,所述验证单元1102具体用于:根据所述第二账户数据和所述第二分支路径中叶子节点和分支节点的数据,确定第二根哈希;若所述第二根哈希等于所述本地存储的第二区块的区块头中状态树的根哈希,则确定所述第二账户数据正确。Optionally, the verification unit 1102 is specifically configured to: determine a second root hash according to the second account data and data of leaf nodes and branch nodes in the second branch path; If it is equal to the root hash of the state tree in the block header of the locally stored second block, it is determined that the second account data is correct.
可选的,所述装置还包括同步单元1103;所述同步单元1103用于:向所述区块链节点发送查询请求;接收所述区块链节点返回的查询结果;所述查询结果是所述区块链节点在接收到所述查询请求后返回的区块链的当前块高;判断所述本地存储的区块头的最高块高是否小于所述当前块高,若是,则向所述区块链节点发送区块头获取请求;所述区块头获取请求中包括待获取区块头的块高;接收所述区块链节点返回的区块头,将接收到的区块头存储在本地。Optionally, the device further includes a synchronization unit 1103; the synchronization unit 1103 is configured to: send a query request to the blockchain node; receive the query result returned by the blockchain node; the query result is all The current block height of the block chain returned by the block chain node after receiving the query request; determine whether the highest block height of the locally stored block header is less than the current block height, and if so, send it to the district The block chain node sends a block header acquisition request; the block header acquisition request includes the block height of the block header to be acquired; receives the block header returned by the blockchain node, and stores the received block header locally.
可选的,所述同步单元1103在所述将接收到的区块头存储在本地之前,还用于:获取所述接收到的区块头中的N个签名信息;根据共识节点列表,对所述N个签名信息验证;所述共识节点列表是根据所述区块链的创世块的区块头至所述接收到的区块头的前一个区块头确定的共识节点组成的列表;若所述N个签名信息通过验证,则确定所述接收到的区块头正确。Optionally, before storing the received block header locally, the synchronization unit 1103 is further configured to: obtain N signature information in the received block header; N signature information verification; the consensus node list is a list of consensus nodes determined from the block header of the genesis block of the blockchain to the previous block header of the received block header; if the N If the signature information is verified, it is determined that the received block header is correct.
可选的,所述同步单元1103具体用于:确定所述N个签名信息对应的N个共识节点;判断所述N个共识节点中在所述共识节点列表中的M个共识节点;若M符合预设条件,则确定所述N个签名信息通过验证。Optionally, the synchronization unit 1103 is specifically configured to: determine the N consensus nodes corresponding to the N signature information; determine the M consensus nodes in the consensus node list among the N consensus nodes; if M If the preset condition is met, it is determined that the N signature information passes the verification.
基于与上述图5或图7所示的方法相同的构思,本申请还提供一种计算设备,如图12所示,该计算设备包括至少一个处理器1220,用于实现本申请实施例提供的图5或图7中任一方法。Based on the same concept as the method shown in FIG. 5 or FIG. 7, the present application also provides a computing device. As shown in FIG. 12, the computing device includes at least one processor 1220 for implementing the method provided in the embodiment of the present application. Either method in Figure 5 or Figure 7.
计算设备1200还可以包括至少一个存储器1230,用于存储程序指令和/或数据。存储器1230和处理器1220耦合。本申请实施例中的耦合是装置、单元或模块之间的间接耦合或通信连接,可以是电性,机械或其它的形式,用于装置、单元或模块之间的信息交互。处理器1220可能和存储器1230协同操作。处理器1220可能执行存储器1230中存储的程序指令。所述至少一个存储器中的至少一个可以包括于处理器中。The computing device 1200 may also include at least one memory 1230 for storing program instructions and/or data. The memory 1230 and the processor 1220 are coupled. The coupling in the embodiments of the present application is an indirect coupling or communication connection between devices, units or modules, and may be in electrical, mechanical or other forms, and is used for information exchange between devices, units or modules. The processor 1220 may operate in cooperation with the memory 1230. The processor 1220 may execute program instructions stored in the memory 1230. At least one of the at least one memory may be included in the processor.
在实现过程中,上述方法的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。结合本申请实施例所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。为避免重复,这里不再详细描述。In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or instructions in the form of software. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware processor, or executed and completed by a combination of hardware and software modules in the processor. The software module can be located in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware. To avoid repetition, it will not be described in detail here.
应注意,本申请实施例中的处理器可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法实施例的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器可以是通用处理器、数字信号处理电路(digital signal processor,DSP)、专用集成芯片(application specific integrated circuit,ASIC)、现场可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本申请实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。It should be noted that the processor in the embodiment of the present application may be an integrated circuit chip with signal processing capability. In the implementation process, the steps of the foregoing method embodiments can be completed by hardware integrated logic circuits in the processor or instructions in the form of software. The above-mentioned processor may be a general-purpose processor, a digital signal processing circuit (digital signal processor, DSP), a dedicated integrated circuit (application specific integrated circuit, ASIC), a field programmable gate array (field programmable gate array, FPGA) or other Programming logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps, and logical block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like. The steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field, such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
可以理解,本申请实施例中的存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(dynamic RAM,DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。应注意,本文描述的系统和方法的存储器旨在包括但不限于这些和任意其它适合类型的存储器。It can be understood that the memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), and electrically available Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory. The volatile memory may be random access memory (RAM), which is used as an external cache. By way of exemplary but not restrictive description, many forms of RAM are available, such as static random access memory (static RAM, SRAM), dynamic random access memory (dynamic RAM, DRAM), and synchronous dynamic random access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous connection dynamic random access memory (synchlink DRAM, SLDRAM) ) And direct memory bus random access memory (direct rambus RAM, DR RAM). It should be noted that the memories of the systems and methods described herein are intended to include, but are not limited to, these and any other suitable types of memories.
计算设备1200还可以包括通信接口1210,用于通过传输介质和其它设备进行通信,从而用于计算设备1200中的装置可以和其它设备进行通信。在本申请实施例中,通信接 口可以是收发器、电路、总线、模块或其它类型的通信接口。在本申请实施例中,通信接口为收发器时,收发器可以包括独立的接收器、独立的发射器;也可以集成收发功能的收发器、或者是接口电路。The computing device 1200 may further include a communication interface 1210 for communicating with other devices through a transmission medium, so that the device used in the computing device 1200 can communicate with other devices. In the embodiment of the present application, the communication interface may be a transceiver, circuit, bus, module, or other type of communication interface. In the embodiment of the present application, when the communication interface is a transceiver, the transceiver may include an independent receiver and an independent transmitter; it may also be a transceiver with integrated transceiver functions, or an interface circuit.
计算设备1200还可以包括通信线路1240。其中,通信接口1210、处理器1220以及存储器1230可以通过通信线路1240相互连接;通信线路1240可以是外设部件互连标准(peripheral component interconnect,简称PCI)总线或扩展工业标准结构(extended industry standard architecture,简称EISA)总线等。所述通信线路1240可以分为地址总线、数据总线、控制总线等。为便于表示,图12中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The computing device 1200 may also include a communication line 1240. Among them, the communication interface 1210, the processor 1220, and the memory 1230 may be connected to each other through a communication line 1240; the communication line 1240 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (extended industry standard architecture). , Referred to as EISA) bus and so on. The communication line 1240 can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 12 to represent it, but it does not mean that there is only one bus or one type of bus.
基于同一发明构思,本发明实施例还提供了一种非暂态计算机可读存储介质,非暂态计算机可读存储介质中存储计算机指令,当其在计算机上运行时,使得计算机执行如图5相关实施例中的区块的状态树的生成方法,或执行如图7相关实施例中的链上数据验证的方法。Based on the same inventive concept, the embodiments of the present invention also provide a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium stores computer instructions, and when it runs on a computer, the computer executes as shown in Figure 5. The method of generating the state tree of the block in the related embodiment, or the method of performing on-chain data verification in the related embodiment of FIG. 7.
基于同一发明构思,本申请实施例提供一种计算机程序产品,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使得计算机执行如图5相关实施例中的区块的状态树的生成方法,或执行如图7相关实施例中的链上数据验证的方法。Based on the same inventive concept, embodiments of the present application provide a computer program product. The computer program product includes a calculation program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When executed by a computer, the computer is caused to execute the method of generating the state tree of the block in the related embodiment of FIG. 5, or execute the method of on-chain data verification in the related embodiment of FIG. 7.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowcharts and/or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and/or block in the flowchart and/or block diagram, and the combination of processes and/or blocks in the flowchart and/or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing equipment to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing equipment are generated It is a device that realizes the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device. The device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment. The instructions provide steps for implementing the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present invention. Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. In this way, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and variations.

Claims (23)

  1. 一种区块的状态树的生成方法,其特征在于,包括:A method for generating a state tree of a block, which is characterized in that it includes:
    针对区块链中的任一区块,确定所述区块的第一账户和第一账户数据;所述第一账户是所述区块中各交易执行后账户数据发生变化的账户,所述第一账户数据是所述各交易执行后所述第一账户中发生变化后的账户数据;For any block in the block chain, determine the first account and first account data of the block; the first account is the account whose account data changes after the execution of each transaction in the block, the The first account data is the account data after the change in the first account after the execution of each transaction;
    构建由各第一账户和所述各第一账户的第一账户数据构成的所述区块的状态树,并将所述状态树的根哈希存储在所述区块的区块头中,其中,所述状态树以键值对的方式存储。Construct a state tree of the block composed of each first account and the first account data of each first account, and store the root hash of the state tree in the block header of the block, wherein , The state tree is stored in the form of key-value pairs.
  2. 如权利要求1所述的方法,其特征在于,所述构建由各第一账户和所述各第一账户的第一账户数据构成的所述区块的状态树,包括:The method according to claim 1, wherein said constructing the state tree of the block composed of each first account and the first account data of each first account comprises:
    针对任一第一账户的任一第一账户数据,将所述第一账户的标识、所述第一账户数据的标识和所述区块的块高作为key值,所述第一账户数据作为叶子节点的value值,基于MPT模式构建所述区块的状态树。For any first account data of any first account, the identification of the first account, the identification of the first account data, and the block height of the block are used as the key value, and the first account data is used as The value value of the leaf node constructs the state tree of the block based on the MPT mode.
  3. 如权利要求2所述的方法,其特征在于,所述第一账户数据包括所述各交易执行后所述第一账户中发生变化的块高记录、账户状态和/或合约状态;所述块高记录用于记录所述第一账户中的账户状态和/或合约状态发生历次变化时所在的区块的块高。The method according to claim 2, wherein the first account data includes block height records, account status and/or contract status that have changed in the first account after the execution of each transaction; the block The high record is used to record the block height of the block where the account status and/or contract status in the first account has been changed.
  4. 如权利要求3所述的方法,其特征在于,所述方法还包括:The method of claim 3, wherein the method further comprises:
    接收客户端的数据获取请求;所述数据获取请求中包括第二账户的标识、第二账户数据的标识和第一块高;Receiving a data acquisition request from the client; the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height;
    根据所述第二账户的标识和所述第二账户的第一块高记录的标识,确定所述第一块高记录;根据所述第二账户的标识、所述第二账户数据的标识、所述第一块高,确定所述第二账户数据;Determine the first high record according to the identifier of the second account and the identifier of the first high record of the second account; according to the identifier of the second account, the identifier of the second account data, The first block is high, and the second account data is determined;
    从第一区块的状态树中获取用于验证所述第一块高记录的第一分支路径;所述第一区块是所述第一块高记录中的最高块高对应的区块;Obtaining a first branch path for verifying the first block height record from the state tree of the first block; the first block is the block corresponding to the highest block height in the first block height record;
    从第二区块的状态树中获取用于验证所述第二账户数据的第二分支路径;所述第二区块是第二块高对应的区块;所述第二块高是所述第一块高记录中低于所述第一块高的所有块高中的最高的块高;Obtain the second branch path for verifying the second account data from the state tree of the second block; the second block is the block corresponding to the second block height; the second block height is the The highest block height of all block heights in the first block height record lower than the first block height;
    将所述第一块高记录、所述第一分支路径、所述第二账户数据、所述第二分支路径发送至所述客户端,以使所述客户端对所述第一块高记录和第二账户数据进行验证。Send the first block of high records, the first branch path, the second account data, and the second branch path to the client, so that the client can record the first block of high records Verification with the second account data.
  5. 一种链上数据验证的方法,其特征在于,包括:A method for on-chain data verification, which is characterized in that it includes:
    向区块链节点发送数据获取请求;所述数据获取请求包括第二账户的标识、第二账户数据的标识和第一块高;Send a data acquisition request to the blockchain node; the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height;
    接收所述区块链节点返回的第一块高记录、第一分支路径、第二账户数据、第二分支路径;所述第一块高记录和所述第二账户数据是所述区块链节点根据所述第二账户的标识、所述第二账户数据的标识和所述第一块高确定的;所述第一分支路径是所述区块链节点确定的用于验证所述第一块高记录的分支路径;所述第二分支路径是所述区块链节点确定的用于验证所述第二账户数据的分支路径;Receive the first block of high records, the first branch path, the second account data, and the second branch path returned by the blockchain node; the first block of high records and the second account data are the blockchain The node is determined according to the identification of the second account, the identification of the second account data, and the first block height; the first branch path is determined by the blockchain node to verify the first The branch path of the block height record; the second branch path is the branch path determined by the blockchain node for verifying the second account data;
    根据所述第一分支路径、本地存储的第一区块的区块头中状态树的根哈希验证所述第一块高记录是否正确;所述本地存储的第一区块的区块头是从所述区块链节点上获取的,所述第一区块是区块链上是所述第一块高记录中的最高块高对应的区块;Verify whether the first block high record is correct according to the first branch path and the root hash of the state tree in the block header of the locally stored first block; the block header of the locally stored first block is from Obtained on the blockchain node, the first block is a block corresponding to the highest block height in the first block height record on the blockchain;
    在确定所述第一块高记录正确之后,根据所述第二分支路径、所述本地存储的第二区块的区块头中状态树的根哈希,验证所述第二账户数据的是否正确;所述本地存储的第二区块的区块头是从所述区块链节点上获取的,所述第二区块是所述区块链上第二块高对应的区块;所述第二块高是所述第一块高记录中低于所述第一块高的所有块高中的最高的块高。After determining that the first block high record is correct, verify whether the second account data is correct according to the second branch path and the root hash of the state tree in the block header of the locally stored second block The block header of the locally stored second block is obtained from the block chain node, and the second block is the block corresponding to the second block on the block chain; the first block The second block height is the highest block height of all block heights lower than the first block height in the first block height record.
  6. 如权利要求5所述的方法,其特征在于,所述根据所述第一分支路径、本地存储的第一区块的区块头中状态树的根哈希验证所述第一块高记录是否正确,包括:The method of claim 5, wherein the first branch path and the root hash of the state tree in the block header of the first block stored locally verify whether the first block high record is correct ,include:
    根据所述第一块高记录和所述第一分支路径中叶子节点和分支节点的数据,确定第一根哈希;Determine the first root hash according to the first block high record and the data of the leaf nodes and the branch nodes in the first branch path;
    若所述第一根哈希等于所述本地存储的第一区块的区块头中状态树的根哈希,则确定所述第一块高记录正确。If the first root hash is equal to the root hash of the state tree in the block header of the locally stored first block, it is determined that the first block high record is correct.
  7. 如权利要求5所述的方法,其特征在于,所述根据所述第二分支路径、所述本地存储的第二区块的区块头中状态树的根哈希,验证所述第二账户数据的是否正确,包括:The method of claim 5, wherein the second account data is verified according to the second branch path and the root hash of the state tree in the block header of the locally stored second block Is correct, including:
    根据所述第二账户数据和所述第二分支路径中叶子节点和分支节点的数据,确定第二根哈希;Determine a second root hash according to the second account data and the data of leaf nodes and branch nodes in the second branch path;
    若所述第二根哈希等于所述本地存储的第二区块的区块头中状态树的根哈希,则确定所述第二账户数据正确。If the second root hash is equal to the root hash of the state tree in the block header of the locally stored second block, it is determined that the second account data is correct.
  8. 如权利要求5所述的方法,其特征在于,所述方法还包括:The method of claim 5, wherein the method further comprises:
    向所述区块链节点发送查询请求;Sending a query request to the blockchain node;
    接收所述区块链节点返回的查询结果;所述查询结果是所述区块链节点在接收到所述查询请求后返回的区块链的当前块高;Receiving the query result returned by the blockchain node; the query result is the current block height of the blockchain returned by the blockchain node after receiving the query request;
    判断所述本地存储的区块头的最高块高是否小于所述当前块高,若是,则向所述区块链节点发送区块头获取请求;所述区块头获取请求中包括待获取区块头的块高;Determine whether the highest block height of the locally stored block header is less than the current block height, and if so, send a block header acquisition request to the blockchain node; the block header acquisition request includes the block header to be acquired high;
    接收所述区块链节点返回的区块头,将接收到的区块头存储在本地。Receive the block header returned by the blockchain node, and store the received block header locally.
  9. 如权利要求8所述的方法,其特征在于,所述将接收到的区块头存储在本地之前,还包括:The method according to claim 8, wherein before storing the received block header locally, the method further comprises:
    获取所述接收到的区块头中的N个签名信息;Acquiring N signature information in the received block header;
    根据共识节点列表,对所述N个签名信息验证;所述共识节点列表是根据所述区块链的创世块的区块头至所述接收到的区块头的前一个区块头确定的共识节点组成的列表;According to the consensus node list, verify the N signature information; the consensus node list is a consensus node determined from the block header of the genesis block of the blockchain to the previous block header of the received block header List of components;
    若所述N个签名信息通过验证,则确定所述接收到的区块头正确。If the N signature information passes the verification, it is determined that the received block header is correct.
  10. 如权利要求9所述的方法,其特征在于,所述根据共识节点列表,对所述N个签名信息验证,包括:The method according to claim 9, wherein the verifying the N signature information according to the consensus node list comprises:
    确定所述N个签名信息对应的N个共识节点;Determining the N consensus nodes corresponding to the N signature information;
    判断所述N个共识节点中在所述共识节点列表中的M个共识节点;Judging the M consensus nodes in the consensus node list among the N consensus nodes;
    若M符合预设条件,则确定所述N个签名信息通过验证。If M meets the preset condition, it is determined that the N signature information passes verification.
  11. 一种区块的状态树的生成装置,其特征在于,包括:A device for generating a state tree of a block is characterized in that it comprises:
    确定单元,用于针对区块链中的任一区块,确定所述区块的第一账户和第一账户数据;所述第一账户是所述区块中各交易执行后账户数据发生变化的账户,所述第一账户数据是所述各交易执行后所述第一账户中发生变化后的账户数据;The determining unit is configured to determine the first account and first account data of the block for any block in the block chain; the first account is the change in account data after each transaction in the block is executed The first account data is the account data after the change in the first account after the execution of each transaction;
    构建单元,用于构建由各第一账户和所述各第一账户的第一账户数据构成的所述区块 的状态树,并将所述状态树的根哈希存储在所述区块的区块头中,其中,所述状态树以键值对的方式存储。The construction unit is used to construct the state tree of the block composed of each first account and the first account data of each first account, and store the root hash of the state tree in the block's In the block header, the state tree is stored in the form of key-value pairs.
  12. 如权利要求11所述的装置,其特征在于,所述构建单元具体用于:The device according to claim 11, wherein the construction unit is specifically configured to:
    针对任一第一账户的任一第一账户数据,将所述第一账户的标识、所述第一账户数据的标识和所述区块的块高作为key值,所述第一账户数据作为叶子节点的value值,基于MPT模式构建所述区块的状态树。For any first account data of any first account, the identification of the first account, the identification of the first account data, and the block height of the block are used as the key value, and the first account data is used as The value value of the leaf node constructs the state tree of the block based on the MPT mode.
  13. 如权利要求12所述的装置,其特征在于,所述第一账户数据包括所述各交易执行后所述第一账户中发生变化的块高记录、账户状态和/或合约状态;所述块高记录用于记录所述第一账户中的账户状态和/或合约状态发生历次变化时所在的区块的块高。The device according to claim 12, wherein the first account data includes a block height record, an account status, and/or a contract status that have changed in the first account after the execution of each transaction; the block The high record is used to record the block height of the block where the account status and/or contract status in the first account has been changed.
  14. 如权利要求13所述的装置,其特征在于,所述装置还包括处理单元;The device according to claim 13, wherein the device further comprises a processing unit;
    所述处理单元用于:The processing unit is used for:
    接收客户端的数据获取请求;所述数据获取请求中包括第二账户的标识、第二账户数据的标识和第一块高;Receiving a data acquisition request from the client; the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height;
    根据所述第二账户的标识和所述第二账户的第一块高记录的标识,确定所述第一块高记录;根据所述第二账户的标识、所述第二账户数据的标识、所述第一块高,确定所述第二账户数据;Determine the first high record according to the identifier of the second account and the identifier of the first high record of the second account; according to the identifier of the second account, the identifier of the second account data, The first block is high, and the second account data is determined;
    从第一区块的状态树中获取用于验证所述第一块高记录的第一分支路径;所述第一区块是所述第一块高记录中的最高块高对应的区块;Obtaining a first branch path for verifying the first block height record from the state tree of the first block; the first block is the block corresponding to the highest block height in the first block height record;
    从第二区块的状态树中获取用于验证所述第二账户数据的第二分支路径;所述第二区块是第二块高对应的区块;所述第二块高是所述第一块高记录中低于所述第一块高的所有块高中的最高的块高;Obtain the second branch path for verifying the second account data from the state tree of the second block; the second block is the block corresponding to the second block height; the second block height is the The highest block height of all block heights in the first block height record lower than the first block height;
    将所述第一块高记录、所述第一分支路径、所述第二账户数据、所述第二分支路径发送至所述客户端,以使所述客户端对所述第一块高记录和第二账户数据进行验证。Send the first block of high records, the first branch path, the second account data, and the second branch path to the client, so that the client can record the first block of high records Verification with the second account data.
  15. 一种链上数据验证的装置,其特征在于,包括:A device for data verification on a chain, which is characterized in that it comprises:
    收发单元,用于向区块链节点发送数据获取请求;所述数据获取请求包括第二账户的标识、第二账户数据的标识和第一块高;The transceiver unit is configured to send a data acquisition request to a blockchain node; the data acquisition request includes the identifier of the second account, the identifier of the second account data, and the first block height;
    所述收发单元,还用于接收所述区块链节点返回的第一块高记录、第一分支路径、第二账户数据、第二分支路径;所述第一块高记录和所述第二账户数据是所述区块链节点根据所述第二账户的标识、所述第二账户数据的标识和所述第一块高确定的;所述第一分支路径是所述区块链节点确定的用于验证所述第一块高记录的分支路径;所述第二分支路径是所述区块链节点确定的用于验证所述第二账户数据的分支路径;The transceiver unit is further configured to receive the first block of high records, the first branch path, the second account data, and the second branch path returned by the blockchain node; the first block of high records and the second branch path The account data is determined by the blockchain node based on the identifier of the second account, the identifier of the second account data, and the first block height; the first branch path is determined by the blockchain node The branch path used to verify the first block of high records; the second branch path is the branch path determined by the blockchain node for verifying the second account data;
    验证单元,用于根据所述第一分支路径、本地存储的第一区块的区块头中状态树的根哈希验证所述第一块高记录是否正确;所述本地存储的第一区块的区块头是从所述区块链节点上获取的,所述第一区块是区块链上是所述第一块高记录中的最高块高对应的区块;The verification unit is configured to verify whether the first block high record is correct according to the first branch path and the root hash of the state tree in the block header of the locally stored first block; the locally stored first block The block header of is obtained from the blockchain node, and the first block is the block corresponding to the highest block height in the first block height record on the blockchain;
    所述验证单元,还用于在确定所述第一块高记录正确之后,根据所述第二分支路径、所述本地存储的第二区块的区块头中状态树的根哈希,验证所述第二账户数据的是否正确;所述本地存储的第二区块的区块头是从所述区块链节点上获取的,所述第二区块是所述区块链上第二块高对应的区块;所述第二块高是所述第一块高记录中低于所述第一块高的所有块高中的最高的块高。The verification unit is further configured to, after determining that the first block high record is correct, verify the root hash of the state tree in the block header of the locally stored second block according to the second branch path Whether the second account data is correct; the block header of the locally stored second block is obtained from the block chain node, and the second block is the second block on the block chain. Corresponding block; the second block height is the highest block height of all block heights lower than the first block height in the first block height record.
  16. 如权利要求15所述的装置,其特征在于,所述验证单元具体用于:The device according to claim 15, wherein the verification unit is specifically configured to:
    根据所述第一块高记录和所述第一分支路径中叶子节点和分支节点的数据,确定第一根哈希;Determine the first root hash according to the first block high record and the data of the leaf nodes and the branch nodes in the first branch path;
    若所述第一根哈希等于所述本地存储的第一区块的区块头中状态树的根哈希,则确定所述第一块高记录正确。If the first root hash is equal to the root hash of the state tree in the block header of the locally stored first block, it is determined that the first block high record is correct.
  17. 如权利要求15所述的装置,其特征在于,所述验证单元具体用于:The device according to claim 15, wherein the verification unit is specifically configured to:
    根据所述第二账户数据和所述第二分支路径中叶子节点和分支节点的数据,确定第二根哈希;Determine a second root hash according to the second account data and the data of leaf nodes and branch nodes in the second branch path;
    若所述第二根哈希等于所述本地存储的第二区块的区块头中状态树的根哈希,则确定所述第二账户数据正确。If the second root hash is equal to the root hash of the state tree in the block header of the locally stored second block, it is determined that the second account data is correct.
  18. 如权利要求15所述的装置,其特征在于,所述装置还包括同步单元;The device according to claim 15, wherein the device further comprises a synchronization unit;
    所述同步单元用于:The synchronization unit is used for:
    向所述区块链节点发送查询请求;Sending a query request to the blockchain node;
    接收所述区块链节点返回的查询结果;所述查询结果是所述区块链节点在接收到所述查询请求后返回的区块链的当前块高;Receiving the query result returned by the blockchain node; the query result is the current block height of the blockchain returned by the blockchain node after receiving the query request;
    判断所述本地存储的区块头的最高块高是否小于所述当前块高,若是,则向所述区块链节点发送区块头获取请求;所述区块头获取请求中包括待获取区块头的块高;Determine whether the highest block height of the locally stored block header is less than the current block height, and if so, send a block header acquisition request to the blockchain node; the block header acquisition request includes the block header to be acquired high;
    接收所述区块链节点返回的区块头,将接收到的区块头存储在本地。Receive the block header returned by the blockchain node, and store the received block header locally.
  19. 如权利要求18所述的装置,其特征在于,所述同步单元在所述将接收到的区块头存储在本地之前,还用于:The apparatus according to claim 18, wherein the synchronization unit is further configured to: before storing the received block header locally:
    获取所述接收到的区块头中的N个签名信息;Acquiring N signature information in the received block header;
    根据共识节点列表,对所述N个签名信息验证;所述共识节点列表是根据所述区块链的创世块的区块头至所述接收到的区块头的前一个区块头确定的共识节点组成的列表;According to the consensus node list, verify the N signature information; the consensus node list is a consensus node determined from the block header of the genesis block of the blockchain to the previous block header of the received block header List of components;
    若所述N个签名信息通过验证,则确定所述接收到的区块头正确。If the N signature information passes the verification, it is determined that the received block header is correct.
  20. 如权利要求19所述的装置,其特征在于,所述同步单元具体用于:The device according to claim 19, wherein the synchronization unit is specifically configured to:
    确定所述N个签名信息对应的N个共识节点;Determining the N consensus nodes corresponding to the N signature information;
    判断所述N个共识节点中在所述共识节点列表中的M个共识节点;Judging the M consensus nodes in the consensus node list among the N consensus nodes;
    若M符合预设条件,则确定所述N个签名信息通过验证。If M meets the preset condition, it is determined that the N signature information passes verification.
  21. 一种计算设备,其特征在于,包括处理器、存储器、通信接口,其中处理器、存储器与通信接口之间通过总线连接;A computing device, which is characterized by comprising a processor, a memory, and a communication interface, wherein the processor, the memory and the communication interface are connected by a bus;
    所述处理器,用于读取所述存储器中的程序,执行权利要求1至4任一所述方法,或权利要求5至10任一所述方法;The processor is configured to read the program in the memory, and execute the method described in any one of claims 1 to 4, or the method described in any one of claims 5 to 10;
    所述存储器,用于存储一个或多个可执行程序,以及存储所述处理器在执行操作时所使用的数据。The memory is used to store one or more executable programs and store data used by the processor when performing operations.
  22. 一种非暂态计算机可读存储介质,其特征在于,所述非暂态计算机可读存储介质存储计算机指令,所述计算机指令用于使所述计算机执行权利要求1至4任一所述方法,或权利要求5至10任一所述方法。A non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to make the computer execute the method described in any one of claims 1 to 4 , Or the method of any one of claims 5 to 10.
  23. 一种计算机程序产品,其特征在于,所述计算机程序产品包括存储在非暂态计算机可读存储介质上的计算程序,所述计算机程序包括程序指令,当所述程序指令被计算机执行时,使所述计算机执行权利要求1至4任一所述方法,或权利要求5至10任一所述方法。A computer program product, characterized in that the computer program product includes a calculation program stored on a non-transitory computer-readable storage medium, the computer program includes program instructions, and when the program instructions are executed by a computer, The computer executes the method described in any one of claims 1 to 4, or the method described in any one of claims 5 to 10.
PCT/CN2020/116269 2019-10-10 2020-09-18 Methods and apparatus for generating state tree of block and validating on-chain data WO2021068728A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910960376.X 2019-10-10
CN201910960376.XA CN110602148B (en) 2019-10-10 2019-10-10 Method and device for generating state tree of block and verifying data on chain

Publications (1)

Publication Number Publication Date
WO2021068728A1 true WO2021068728A1 (en) 2021-04-15

Family

ID=68866285

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/116269 WO2021068728A1 (en) 2019-10-10 2020-09-18 Methods and apparatus for generating state tree of block and validating on-chain data

Country Status (2)

Country Link
CN (2) CN113329031B (en)
WO (1) WO2021068728A1 (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113704249A (en) * 2021-07-14 2021-11-26 杭州溪塔科技有限公司 Method and device for using static Mercker tree in block chain
CN114385756A (en) * 2021-06-17 2022-04-22 支付宝(杭州)信息技术有限公司 Method for executing transaction in block chain and block chain link point
CN114520810A (en) * 2022-01-27 2022-05-20 山东浪潮工业互联网产业股份有限公司 Block chain-based block data transmission method, equipment and medium
CN115021945A (en) * 2022-08-08 2022-09-06 四块科技(深圳)有限公司 Block chain transaction processing method and system
CN115052008A (en) * 2022-05-26 2022-09-13 南京邮电大学 Block chain data link down-link storage method based on cloud storage
CN115150417A (en) * 2022-07-01 2022-10-04 南方电网电力科技股份有限公司 Data storage method based on block chain and related device
WO2023016091A1 (en) * 2021-08-11 2023-02-16 腾讯科技(深圳)有限公司 Data archiving method and apparatus, device, storage medium, and computer program product
CN115941692A (en) * 2023-03-09 2023-04-07 中国信息通信研究院 Information identification system, device and medium based on master-slave block chain storage mode
WO2023207080A1 (en) * 2022-04-28 2023-11-02 蚂蚁区块链科技(上海)有限公司 Data processing method in blockchain, and blockchain node
CN117251120A (en) * 2023-11-17 2023-12-19 杭州乒乓智能技术有限公司 Accounting system optimization method, device, equipment and medium based on jvm out-of-heap memory

Families Citing this family (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113329031B (en) * 2019-10-10 2023-06-13 深圳前海微众银行股份有限公司 Method and device for generating state tree of block
CN111177225B (en) * 2020-01-02 2023-05-23 支付宝(杭州)信息技术有限公司 Account state existence proving method and device and state inquiring method and device
CN111209339B (en) * 2020-01-03 2021-09-14 腾讯科技(深圳)有限公司 Block synchronization method, device, computer and storage medium
CN113312205B (en) * 2020-02-26 2022-07-29 腾讯科技(深圳)有限公司 Data verification method and device, storage medium and computer equipment
CN111461751B (en) * 2020-04-02 2024-03-29 武汉大学 Real estate information chain organization method based on block chain, historical state tracing method and device
CN111488615A (en) * 2020-04-08 2020-08-04 北京瑞策科技有限公司 Cross-link realization method and device for service data block chain
CN111488606B (en) * 2020-04-08 2021-04-27 北京瑞策科技有限公司 Data sharing method and device based on service data block chain
CN111488610A (en) * 2020-04-08 2020-08-04 北京瑞策科技有限公司 State data query method and device based on service data block chain
CN111488359A (en) * 2020-04-08 2020-08-04 北京瑞策科技有限公司 Relation data storage method and device of business data block chain
CN111553669B (en) * 2020-04-28 2021-09-10 腾讯科技(深圳)有限公司 Transaction routing method, device and computer readable storage medium
CN111553670B (en) * 2020-04-28 2021-10-15 腾讯科技(深圳)有限公司 Transaction processing method and device and computer readable storage medium
CN111640018B (en) * 2020-05-06 2021-08-03 深圳前海微众银行股份有限公司 Block chain transaction existence verification method and device
CN112286939A (en) * 2020-06-12 2021-01-29 支付宝(杭州)信息技术有限公司 Method, device and equipment for generating Hash of global state in block chain type account book
CN112364010B (en) * 2021-01-12 2021-04-23 支付宝(杭州)信息技术有限公司 Method and device for verifying existence of important business record
CN113254450B (en) * 2021-05-28 2022-07-22 山大地纬软件股份有限公司 Method and system for storing account state of incremental MPT (message passing test) tree based on block chain
CN113505138B (en) * 2021-09-06 2021-12-21 支付宝(杭州)信息技术有限公司 Method and apparatus for state attestation and execution of blocks in a blockchain system
CN114691687B (en) * 2021-12-30 2022-12-06 北京连琪科技有限公司 Method for verifying block state certification
CN114564539B (en) * 2022-03-01 2022-11-25 山东大学 Dynamic building method and system of block chain world state for account liveness perception

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018115567A1 (en) * 2016-12-19 2018-06-28 Nokia Technologies Oy Method and apparatus for private data transfer between parties
CN108615156A (en) * 2018-05-09 2018-10-02 上海魅联信息技术有限公司 A kind of data structure based on block chain
CN109213900A (en) * 2018-09-18 2019-01-15 百度在线网络技术(北京)有限公司 A kind of data modification method, device, equipment and the medium of block chain
CN109359222A (en) * 2018-08-06 2019-02-19 杭州复杂美科技有限公司 Date storage method and system, equipment and storage medium
CN109409889A (en) * 2018-11-13 2019-03-01 杭州秘猿科技有限公司 A kind of block in block chain determines method, apparatus and electronic equipment
CN110009334A (en) * 2018-11-07 2019-07-12 阿里巴巴集团控股有限公司 A kind of building Mei Keer tree, simple payment verification method and device
CN110060064A (en) * 2019-04-26 2019-07-26 深圳市网心科技有限公司 A kind of Transaction Information verification method and relevant apparatus
CN110602148A (en) * 2019-10-10 2019-12-20 深圳前海微众银行股份有限公司 Method and device for generating state tree of block and verifying data on chain
CN111008201A (en) * 2020-03-09 2020-04-14 支付宝(杭州)信息技术有限公司 Method and apparatus for parallel modification and reading of state trees

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10097344B2 (en) * 2016-07-15 2018-10-09 Mastercard International Incorporated Method and system for partitioned blockchains and enhanced privacy for permissioned blockchains
CN106503992A (en) * 2016-10-18 2017-03-15 北京天德科技有限公司 A kind of block chain that Transaction Information and accounts information are stored respectively
US10255342B2 (en) * 2017-04-12 2019-04-09 Vijay K. Madisetti Method and system for tuning blockchain scalability, decentralization, and security for fast and low-cost payment and transaction processing
CN108039943B (en) * 2017-12-06 2020-10-30 清华大学深圳研究生院 Verifiable encryption searching method
CN108197226A (en) * 2017-12-29 2018-06-22 山大地纬软件股份有限公司 MPTC account status tree and MPTC block chain method for quickly retrieving
CN108282474B (en) * 2018-01-18 2020-04-17 山东大学 Block chain based digital asset transaction consistency maintenance method
CN108153907B (en) * 2018-01-18 2021-01-22 中国计量大学 Dictionary storage management method for realizing space optimization through 16-bit Trie tree
CN110400142B (en) * 2018-06-01 2021-06-25 腾讯科技(深圳)有限公司 Data processing method, device and storage medium
CN108595720B (en) * 2018-07-12 2020-05-19 中国科学院深圳先进技术研究院 Block chain space-time data query method, system and electronic equipment
CN109145163B (en) * 2018-08-22 2021-08-24 深圳前海微众银行股份有限公司 Block chain data capacity reduction method and device and storage medium
CN109359159A (en) * 2018-09-30 2019-02-19 深圳前海微众银行股份有限公司 Distributed storage method, system and equipment
CN109684333B (en) * 2018-12-24 2021-02-09 杭州复杂美科技有限公司 Data storage and cutting method, equipment and storage medium
CN109829267A (en) * 2019-02-22 2019-05-31 陕西优米数据技术有限公司 A kind of copyright common recognition system and method based on block chain
CN109933592B (en) * 2019-03-22 2021-06-01 杭州复杂美科技有限公司 Data storage method, data rollback method, device and storage medium
CN110188550A (en) * 2019-05-17 2019-08-30 深圳前海微众银行股份有限公司 A kind of data verification method and device of block chain
WO2019179538A2 (en) * 2019-07-11 2019-09-26 Alibaba Group Holding Limited Shared blockchain data storage

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018115567A1 (en) * 2016-12-19 2018-06-28 Nokia Technologies Oy Method and apparatus for private data transfer between parties
CN108615156A (en) * 2018-05-09 2018-10-02 上海魅联信息技术有限公司 A kind of data structure based on block chain
CN109359222A (en) * 2018-08-06 2019-02-19 杭州复杂美科技有限公司 Date storage method and system, equipment and storage medium
CN109213900A (en) * 2018-09-18 2019-01-15 百度在线网络技术(北京)有限公司 A kind of data modification method, device, equipment and the medium of block chain
CN110009334A (en) * 2018-11-07 2019-07-12 阿里巴巴集团控股有限公司 A kind of building Mei Keer tree, simple payment verification method and device
CN109409889A (en) * 2018-11-13 2019-03-01 杭州秘猿科技有限公司 A kind of block in block chain determines method, apparatus and electronic equipment
CN110060064A (en) * 2019-04-26 2019-07-26 深圳市网心科技有限公司 A kind of Transaction Information verification method and relevant apparatus
CN110602148A (en) * 2019-10-10 2019-12-20 深圳前海微众银行股份有限公司 Method and device for generating state tree of block and verifying data on chain
CN111008201A (en) * 2020-03-09 2020-04-14 支付宝(杭州)信息技术有限公司 Method and apparatus for parallel modification and reading of state trees

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
尤瑶 等 (YOU, YAO ET AL.): "一种支持区块链交易溯源的混合索引机制 (Hybrid Indexing Scheme Supporting blockchain Transaction Tracing)", 计算机集成制造系统 (COMPUTER INTEGRATED MANUFACTURING SYSTEMS), vol. 25, no. 4, 30 April 2019 (2019-04-30), XP055776546, DOI: 10.13196/j.cims.2019.04.021 *

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114385756A (en) * 2021-06-17 2022-04-22 支付宝(杭州)信息技术有限公司 Method for executing transaction in block chain and block chain link point
CN113704249A (en) * 2021-07-14 2021-11-26 杭州溪塔科技有限公司 Method and device for using static Mercker tree in block chain
WO2023016091A1 (en) * 2021-08-11 2023-02-16 腾讯科技(深圳)有限公司 Data archiving method and apparatus, device, storage medium, and computer program product
CN114520810A (en) * 2022-01-27 2022-05-20 山东浪潮工业互联网产业股份有限公司 Block chain-based block data transmission method, equipment and medium
WO2023207080A1 (en) * 2022-04-28 2023-11-02 蚂蚁区块链科技(上海)有限公司 Data processing method in blockchain, and blockchain node
CN115052008B (en) * 2022-05-26 2023-07-25 南京邮电大学 Block chain data under-chain storage method based on cloud storage
CN115052008A (en) * 2022-05-26 2022-09-13 南京邮电大学 Block chain data link down-link storage method based on cloud storage
CN115150417A (en) * 2022-07-01 2022-10-04 南方电网电力科技股份有限公司 Data storage method based on block chain and related device
CN115021945B (en) * 2022-08-08 2022-11-08 四块科技(深圳)有限公司 Block chain transaction processing method and system
CN115021945A (en) * 2022-08-08 2022-09-06 四块科技(深圳)有限公司 Block chain transaction processing method and system
CN115941692B (en) * 2023-03-09 2023-05-23 中国信息通信研究院 Information identification system, equipment and medium based on master-slave block chain storage mode
CN115941692A (en) * 2023-03-09 2023-04-07 中国信息通信研究院 Information identification system, device and medium based on master-slave block chain storage mode
CN117251120A (en) * 2023-11-17 2023-12-19 杭州乒乓智能技术有限公司 Accounting system optimization method, device, equipment and medium based on jvm out-of-heap memory
CN117251120B (en) * 2023-11-17 2024-03-01 杭州乒乓智能技术有限公司 Accounting system optimization method, device, equipment and medium based on jvm out-of-heap memory

Also Published As

Publication number Publication date
CN110602148A (en) 2019-12-20
CN113329031B (en) 2023-06-13
CN113329031A (en) 2021-08-31
CN110602148B (en) 2021-07-06

Similar Documents

Publication Publication Date Title
WO2021068728A1 (en) Methods and apparatus for generating state tree of block and validating on-chain data
WO2021077962A1 (en) Method and apparatus for blockchain node synchronization
WO2021036702A1 (en) Consensus method and device employing blockchain system
US10642643B2 (en) Method and apparatus for writing service data into block chain and method for determining service subset
WO2021032138A1 (en) Consensus method and device based on blockchain system, and system
US20200019545A1 (en) Method and device for writing service data in block chain system
WO2021027531A1 (en) Block chain transaction record processing method and device
WO2020248982A1 (en) Method and device for transaction processing in blockchain
CN109542979B (en) Fast synchronization and simple data storage mode of block chain system
WO2021120925A1 (en) Block synchronization method and device
KR20210003234A (en) Maintaining blocks of a blockchain in a segmented blockchain network
WO2021103997A1 (en) Blockchain certificate revocation and verification methods, issuing node, and verification node
CN111131171B (en) Node authentication method and device based on block chain network
WO2020015533A1 (en) Transaction processing method and apparatus, and blockchain system
CN112579602B (en) Multi-version data storage method, device, computer equipment and storage medium
CN111651300B (en) Block chain data recovery method, device, equipment and medium
CN112559529B (en) Data storage method, device, computer equipment and storage medium
WO2022078181A1 (en) Method and apparatus for proving blockchain transaction
CN110555700A (en) block chain intelligent contract execution method and device and computer readable storage medium
WO2023184052A1 (en) Data processing method, blockchain node and blockchain system
CN112131235A (en) Method for realizing transaction credibility verification in block chain system
WO2021115002A1 (en) Method and apparatus for processing blockchain transaction record
CN115795563A (en) State data checking method and device
US20230275772A1 (en) Consensus processing method, apparatus, and system for blockchain network, device, and medium
CN111147477A (en) Verification method and device based on block chain network

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20875265

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 18/08/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 20875265

Country of ref document: EP

Kind code of ref document: A1