WO2021114926A1 - 用于生成多层块链式结构的方法及装置 - Google Patents

用于生成多层块链式结构的方法及装置 Download PDF

Info

Publication number
WO2021114926A1
WO2021114926A1 PCT/CN2020/124446 CN2020124446W WO2021114926A1 WO 2021114926 A1 WO2021114926 A1 WO 2021114926A1 CN 2020124446 W CN2020124446 W CN 2020124446W WO 2021114926 A1 WO2021114926 A1 WO 2021114926A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
layer
block chain
chain layer
upper block
Prior art date
Application number
PCT/CN2020/124446
Other languages
English (en)
French (fr)
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 WO2021114926A1 publication Critical patent/WO2021114926A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2219Large Object storage; Management thereof

Definitions

  • the embodiments of this specification relate to the field of blockchain technology, in particular, to a method and device for generating a multi-layer blockchain structure.
  • the blockchain network is a decentralized distributed data storage system involving multiple nodes. Once data is written to the blockchain on each node, on the one hand, it means that the data is disclosed in the blockchain network. On the other hand, the data written to the blockchain is also difficult to delete and tamper with.
  • centralized devices can also store data in a manner similar to blockchain storage (which can be regarded as centralized blockchain storage).
  • systems that store data in a block-chain manner such as blockchain systems and quasi-blockchain systems, are called block-chain systems.
  • the block chain data is very large, and over time, the amount of data will continue to grow.
  • the traditional block chain structure if you want to synchronize, verify, or query the data stored on the block chain, the amount of data access and calculation is huge. Therefore, there is an urgent need for a technology that can improve the operation efficiency of block chain data.
  • the embodiments of this specification provide a method and device for generating a multi-layer block chain structure.
  • the method and device can be used to generate a block chain with a multi-layer structure.
  • a method for generating a multi-layer block chain structure includes a bottom block chain layer and an upper block chain layer
  • the method includes : Generate blocks of the bottom block chain layer in the multi-layer block chain structure based on transaction data; and generate the upper block chain layer based on the bottom block chain layer according to the upper block chain layer generation conditions, where, according to the upper block
  • the chain layer generation condition, based on the underlying block chain layer to generate the upper block chain layer includes: determining whether there is a reference block in the lower block chain layer that triggers the generation condition of the upper block chain layer; respond to the underlying block chain layer There is a reference block that triggers the generation condition of the upper block chain layer, and the corresponding upper block of the upper block chain layer is generated based at least in part on the block information of the reference block.
  • the multi-layer block chain structure includes a plurality of upper block chain layers
  • the method may further include: for each upper block chain layer, according to the same or different upper block chain layers Based on the upper block chain layer generation condition, the adjacent upper block chain layer of the upper block chain layer is generated based on the upper block chain layer.
  • the conditions for generating the upper block chain layer may include: the number of blocks between two adjacent reference blocks in the bottom block chain layer reaches a specified number; or in the bottom block chain layer The generation time interval of two adjacent reference blocks reaches the specified time interval.
  • the specified number or specified time interval in each block chain layer in the multi-layer block chain structure may be the same or different, and the specified number or time interval between each block chain layer The specified time interval can be the same or different.
  • the method may further include: determining whether the newly generated block meets the generation conditions of the upper-level block-chain-type layer for each layer of the block-chain type in the multi-layer block-chain type structure The benchmark block.
  • generating the corresponding upper block of the upper block chain layer may include: based on the first block of each block chain layer to the reference block The block information of at least some of the blocks in all the blocks is generated to generate the corresponding upper block of the adjacent upper block chain layer of the block chain layer.
  • the method may further include: storing block index information of the reference block and the corresponding upper-layer block.
  • the block index information may be the block height of the reference block or the corresponding upper block.
  • the block index information may be included in a reference block or a corresponding upper block, or the block index information may be stored in an index database.
  • the header block of each upper block chain layer in the multi-layer block chain structure may include the hash value of the genesis block of the bottom block chain layer.
  • a device for generating a multi-layer block chain structure includes a bottom block chain layer and an upper block chain layer, the device Including: the bottom block chain layer generating unit, based on transaction data to generate the blocks of the bottom block chain layer in the multi-layer block chain structure; and the upper block chain layer generating unit, based on the upper block chain layer generation conditions, based on The bottom block chain layer generates the upper block chain layer, wherein the upper block chain layer generating unit includes: a reference block determination module, which determines whether there is a benchmark that triggers the generation condition of the upper block chain layer in the bottom block chain layer Block; the upper block chain layer generation module, in response to the presence of a reference block in the lower block chain layer that triggers the block generation condition of the upper block chain layer, generates the upper layer based at least in part on the block information of the reference block The corresponding upper block of the block chain layer.
  • the multi-layer block chain structure includes a plurality of upper block chain layers, and wherein the upper block chain layer generating unit is also directed to each upper block chain layer according to the same or different
  • the upper block chain layer generation condition is based on the upper block chain layer to generate the upper block chain layer adjacent to the upper block chain layer.
  • the conditions for generating the upper block chain layer may include: the number of blocks between two adjacent reference blocks in the bottom block chain layer reaches a specified number; or in the bottom block chain layer The generation time interval of two adjacent reference blocks reaches the specified time interval.
  • the reference block determination module determines whether the newly generated block meets the generation conditions of the upper block chain layer for each layer of the block chain layer in the multi-layer block chain structure The benchmark block.
  • the upper-level block chain layer generation module may be based on at least some of the blocks from the first block of each block chain layer to the reference block. Information, the corresponding upper block of the adjacent upper block chain layer of the block chain layer is generated.
  • the device may further include: a block index information storage unit, which stores block index information of the reference block and the corresponding upper block.
  • the block index information storage unit may store the block index information in a reference block or a corresponding upper block, or store the block index information in an index database .
  • a computing device including: at least one processor; and a memory, the memory stores instructions, and when the instructions are executed by the at least one processor, the At least one processor executes the method as described above.
  • a non-transitory machine-readable storage medium which stores executable instructions, which when executed cause the machine to execute the method as described above.
  • the corresponding upper zone of the upper block chain layer is generated based at least in part on the block information of the reference block Block, which can generate a multi-layer block chain structure.
  • the multi-layer block chain structure when performing related operations on the data in the block chain structure, it is not necessary to visit each block of the underlying block chain layer one by one, which can reduce the amount of data access and the amount of calculation to improve the operation effectiveness.
  • FIG. 1 shows a schematic diagram of an example of an environment that can be used to perform a method for generating a multi-layer block chain structure and a method for updating trust points in a multi-layer block chain structure according to an embodiment of the present specification ;
  • FIG. 2 shows a schematic diagram of an example of a system architecture that executes the method for generating a multi-layer block chain structure and the method for updating trust points in the multi-layer block chain structure according to an embodiment of the present specification;
  • Fig. 3 is a flowchart of a method for generating a multi-layer block chain structure according to an embodiment of the present specification
  • Fig. 4 is a schematic diagram of a multi-layer block chain structure according to an embodiment of the present specification.
  • 5A is a flowchart of a reference block determination process in a method for generating a multi-layer block chain structure according to an embodiment of the present specification
  • FIG. 5B is an example flowchart of the reference block determination process in the method for generating a multi-layer block chain structure according to an embodiment of the present specification
  • 6A is another example flowchart of the reference block determination process in the method for generating a multi-layer block chain structure according to an embodiment of the present specification
  • 6B is another example flowchart of the reference block determination process in the method for generating a multi-layer block chain structure according to an embodiment of the present specification
  • FIG. 7 is a flowchart of a method for updating trust points in a multi-layer block chain structure according to an embodiment of the present specification
  • FIG. 8 is a flowchart of a link verification process in a method for updating a trust point in a multi-layer block chain structure according to an embodiment of the present specification
  • FIG. 9 is a flowchart of a method for updating trust points in a multi-layer block chain structure according to another embodiment of the present specification.
  • FIG. 10 is a flowchart of a target underlying block verification process in a method for updating trust points in a multi-layer block chain structure according to an embodiment of the present specification
  • FIG. 11 is a flowchart of a method for performing SPV verification on a transaction to be verified according to an embodiment of the present specification
  • FIG. 12 is a structural block diagram of a device for generating a multi-layer block chain structure according to an embodiment of the present specification
  • FIG. 13 is a structural block diagram of an apparatus for updating trust points in a multi-layer block chain structure according to an embodiment of the present specification
  • FIG. 14 is a structural block diagram of a link verification unit in the device for updating trust points in a multi-layer block chain structure shown in FIG. 13;
  • FIG. 15 is a structural block diagram of a target bottom-level block verification unit in the device for updating trust points in a multi-layer block chain structure shown in FIG. 13;
  • Fig. 16 is a structural block diagram of a computing device for implementing a method for generating a multi-layer block chain structure or a method for updating a trust point in a multi-layer block chain structure according to an embodiment of the present specification.
  • the term “including” and its variations mean open terms, meaning “including but not limited to”.
  • the term “based on” means “based at least in part on.”
  • the terms “one embodiment” and “an embodiment” mean “at least one embodiment.”
  • the term “another embodiment” means “at least one other embodiment.”
  • the terms “first”, “second”, etc. may refer to different or the same objects. Other definitions can be included below, whether explicit or implicit. Unless clearly indicated in the context, the definition of a term is consistent throughout the specification.
  • Blockchain is a chain data structure that connects and combines data blocks sequentially in chronological order, and cryptographically ensures that the data blocks cannot be tampered with or forged.
  • the blockchain includes one or more blocks. Each block in the blockchain is linked to the previous block by including the encrypted hash of the immediately preceding block in the blockchain. Each block also includes a timestamp, a cryptographic hash of the block, and one or more transactions.
  • the transaction that has been verified by the nodes of the blockchain network is hashed and a Merkle tree is formed. In the Merkle tree, the data at the leaf nodes is hashed, and for each branch of the Merkle tree, all the hash values of the branch are concatenated at the root of the branch.
  • the above processing is performed on the Merkle tree until the root node of the entire Merkle tree.
  • the root node of the Merkle tree stores hash values representing all data in the Merkle tree.
  • Blockchain is a data structure used to store transactions.
  • the blockchain network is a network of computing nodes used to manage, update and maintain one or more blockchain structures.
  • the blockchain network can include a public blockchain network, a private blockchain network, or a consortium blockchain network.
  • the consensus process is controlled by the nodes of the consensus network.
  • the public blockchain network can be considered as a public network of participating entities.
  • most entities nodes must sign each block in sequence, and add the signed block to the blockchain of the blockchain network.
  • Examples of public blockchain networks may include specific peer-to-peer payment networks.
  • blockchain does not specifically refer to any particular blockchain.
  • the public blockchain network supports public transactions. Public transactions are shared among all nodes in the public blockchain network and stored in the global blockchain.
  • a global blockchain refers to a blockchain that is replicated across all nodes.
  • consensus protocols include but are not limited to: proof-of-work (POW), proof-of-stake (POS), and proof-of-authority (POA).
  • POW is used as a non-limiting example.
  • Private blockchain networks are provided for specific entities.
  • the read and write permissions of each node in the private blockchain network are strictly controlled. Therefore, a private blockchain network is usually also called a permissioned network, which restricts who is allowed to participate in the network and the level of network participation (for example, only in certain transaction situations).
  • a private blockchain network various types of access control mechanisms can be used (for example, existing participants vote to add new entities, regulatory agencies control permissions, etc.).
  • the alliance blockchain network is private among participating entities.
  • the consensus process is controlled by authorized nodes.
  • a consortium composed of several (for example, 10) entities (for example, financial institutions, insurance companies) can operate a consortium blockchain network, and each entity operates at least one node in the consortium blockchain network. Therefore, the consortium blockchain network can be considered as a private network of participating entities.
  • each participating entity node
  • each block may be signed by a subset of participating entities (nodes) (for example, at least 7 entities), and the block may be added to the blockchain.
  • Blockchain is a tamper-proof shared digital ledger that records transactions in a public or private peer-to-peer network.
  • the ledger is distributed to all member nodes in the network, and the history of asset transactions that occurred in the network is permanently recorded in the block.
  • the consensus mechanism ensures that all network nodes in the distributed blockchain network execute transactions in the same order and then write to the same ledger.
  • the consensus model aims to solve the Byzantine problem.
  • components such as servers or network nodes in the distributed blockchain network may malfunction or deliberately spread wrong information to other nodes. Since other network nodes need to reach a consensus on which network node fails first, it is difficult for other network nodes to declare the component failure and exclude it from the blockchain network.
  • FIG. 1 shows a schematic diagram of an example of an environment 100 that can be used to perform a method for generating a multi-layer block chain structure and a method for updating trust points in a blockchain according to an embodiment of the present specification.
  • the environment 100 enables entities to participate in the blockchain network 102.
  • the environment 100 includes a network 104, and computing devices/systems 106, 108.
  • the network 104 may include a local area network (LAN), a wide area network (WAN), the Internet, or a combination thereof, and connect a website, a user device (for example, a computing device), and a back-end system.
  • the network 104 may be accessed through a wired and/or wireless communication link.
  • the computing devices/systems 106 and 108 communicate with each other through the network 104, and communicate with the blockchain network 102 through the network 104, and the nodes (or node devices) in the blockchain network 102 pass through The network 104 communicates.
  • the network 104 represents one or more communication networks.
  • the computing devices/systems 106, 108 may be nodes of a cloud computing system (not shown), or each computing device/system 106, 108 may be a separate cloud computing system, including interconnection through the network 104 Multiple computers and used as a distributed processing system.
  • each of the computing devices/systems 106, 108 may include any suitable computing system capable of participating as a node in the blockchain network 102.
  • Examples of computing devices/systems include, but are not limited to, servers, desktop computers, laptops, tablet devices, smart phones, etc.
  • one or more computer-implemented services for interacting with the blockchain network 102 may be installed on the computing device/system 106, 108.
  • the computing device/system 106 may be installed with the services of the first entity (for example, user A), for example, the first entity is used to manage transactions with one or more other entities (for example, other users). Management system.
  • the computing device/system 108 may be installed with services of a second entity (for example, user B), for example, a transaction management system used by the second entity to manage transactions with one or more other entities (for example, other users) .
  • a second entity for example, user B
  • a transaction management system used by the second entity to manage transactions with one or more other entities (for example, other users) .
  • the blockchain network 102 is represented as a peer-to-peer network of nodes, and the computing devices/systems 106, 108 serve as the nodes of the first entity and the second entity participating in the blockchain network 102, respectively.
  • FIG. 2 shows a schematic diagram of an example of a system architecture 200 that executes the method for generating a multi-layer block chain structure and the method for updating trust points in the multi-layer block chain structure according to an embodiment of the present specification .
  • An example of the system architecture 200 includes the participant systems 202, 204, and 206 corresponding to the participant A, the participant B, and the participant C, respectively.
  • Each participant eg, user, enterprise
  • the blockchain network 212 includes a plurality of nodes 214, wherein at least some of the nodes 214 record information in the blockchain 216, and the recorded information cannot be changed.
  • a single blockchain 216 is schematically shown within the blockchain network 212, multiple copies of the blockchain 216 may be provided, and multiple copies are maintained in the blockchain network 212, as described in detail later of.
  • each participant system 202, 204, 206 is provided by participant A, participant B, and participant C, or provided as participant A, participant B, and participant C, respectively, And it serves as the corresponding node 214 in the blockchain network 212.
  • a node generally refers to a single system (eg, computer, server) connected to the blockchain network 212 and enables corresponding participants to participate in the blockchain network.
  • the participant corresponds to each node 214.
  • one participant can operate multiple nodes 214 within the blockchain network 212, and/or multiple participants can share a single node 214.
  • the participant systems 202, 204, 206 use protocols (e.g., Hypertext Transfer Protocol Security (HTTPS)) and/or use remote procedure calls (RPC) to communicate with the blockchain network 212, or through the blockchain
  • HTTPS Hypertext Transfer Protocol Security
  • RPC remote procedure calls
  • the degree of participation of the node 214 in the blockchain network 212 may vary. For example, some nodes 214 may participate in the consensus process (eg, as miner nodes that add blocks to the blockchain 216), while other nodes 214 do not participate in the consensus process. As another example, some nodes 214 store a complete copy of the blockchain 216, while other nodes 214 only store a partial copy of the blockchain 216. In the example of Figure 2, the participant systems 202, 204, 206 each store a complete copy of the blockchain 216 216', 216", 216"'.
  • a blockchain (for example, the blockchain 216 in FIG. 2) is composed of a series of blocks, and each block stores data.
  • Examples of data may include transaction data representing transactions between two or more participants.
  • transactions are used as a non-limiting example, and it is expected that any appropriate data can be stored in the blockchain (for example, documents, images, videos, audios).
  • Examples of transactions may include, but are not limited to, the exchange of valuable things (for example, assets, products, services, currency, etc.).
  • Transaction data is stored immutably in the blockchain.
  • hash Before storing in the block, hash the transaction data. Hashing is the process of converting transaction data (provided as string data) into a fixed-length hash value (also provided as string data). After the transaction data is hashed, even a slight change in the transaction data will result in a completely different hash value.
  • the hash value is usually generated by hashing transaction data using a hash function. Examples of hash functions include, but are not limited to, Secure Hash Algorithm (SHA)-256, which outputs a 256-bit hash value.
  • SHA Secure Hash Algorithm
  • the transaction data of multiple transactions can be stored in the block after being hashed. For example, two transaction data are hashed to obtain two hash values, and then the two obtained hash values are hashed again to obtain another hash value. This process is repeated until a single hash value is obtained for all transactions to be stored in the block.
  • This hash value is called the Merkle root hash and is stored at the head of the block. Any change in the transaction will cause its hash value to change, and eventually the Merkle root hash value will change.
  • the block is added to the blockchain through a consensus protocol.
  • Multiple nodes in the blockchain network participate in the consensus protocol and add blocks to the blockchain after competition.
  • Such nodes are called miner nodes (or accounting nodes).
  • the POW introduced above serves as a non-limiting example.
  • Miner nodes perform a consensus process to add transactions (corresponding blocks) to the blockchain. Although multiple miner nodes participate in the consensus process, only one miner node can write a block to the blockchain. In other words, miner nodes compete in the consensus process to add their blocks to the blockchain. In more detail, the miner node periodically collects pending transactions from the transaction pool (for example, until a predetermined limit on the number of transactions that can be included in the block is reached, if any). The transaction pool includes transaction messages from participants in the blockchain network. Miner nodes create blocks and add transactions to the blocks. Before adding the transaction to the block, the miner node checks whether there is a transaction in the block of the blockchain among the transactions to be added. If the transaction has been added to another block, the transaction will be discarded.
  • the miner node generates a block header, hashes all transactions in the block, and combines the hash values in pairs to generate further hash values until a single hash value (Merkle root) is obtained for all transactions in the block. Hash). Then, add the Merkle root hash to the block header.
  • the miner also determines the hash value of the latest block in the blockchain (ie, the last block added to the blockchain). Miner nodes can also add random values (noune values) and timestamps to the block header.
  • the miner node tries to find a hash value that meets the required parameters. The miner node keeps changing the nonce value until it finds a hash value that meets the required parameters.
  • Every miner in the blockchain network tries to find a hash value that meets the required parameters and competes with each other in this way.
  • a miner node finds a hash value that meets the required parameters and advertises the hash value to all other miner nodes in the blockchain network.
  • Other miner nodes verify the hash value, and if it is determined to be correct, verify each transaction in the block, accept the block, and attach the block to their copy of the blockchain. In this way, the global state of the blockchain is agreed upon on all miner nodes within the blockchain network.
  • the above process is a POW consensus protocol.
  • participant A wants to send a certain amount of funds to participant B.
  • Participant A generates a transaction message and sends the transaction message to the blockchain network, and the transaction message is added to the transaction pool.
  • Each miner node in the blockchain network creates a block, obtains transactions from the transaction pool, and adds the transaction to the block. In this way, the transaction issued by participant A is added to the block of the miner node.
  • cryptography is implemented to maintain the privacy of transactions. For example, if two nodes want to maintain the privacy of the transaction so that other nodes in the blockchain network cannot learn the details of the transaction, the node can encrypt the transaction data.
  • encryption methods include, but are not limited to, symmetric encryption and asymmetric encryption.
  • Symmetric encryption refers to the encryption process that uses a single key to encrypt (generate ciphertext based on plaintext) and decrypt (generate plaintext based on ciphertext).
  • symmetric encryption multiple nodes can use the same key, so each node can encrypt/decrypt transaction data.
  • Asymmetric encryption refers to the use of key pairs for encryption.
  • Each key pair includes a private key and a public key.
  • the private key is only known to the corresponding node, and the public key is known to any or all other nodes in the blockchain network.
  • a node can use another node's public key to encrypt data, and can use another node's private key to decrypt the encrypted data.
  • Participant A can use the public key of participant B to encrypt data and send the encrypted data to participant B.
  • Participant B can use its private key to decrypt the encrypted data (ciphertext) and extract the original data (plain text). Messages encrypted with the public key of the node can only be decrypted with the private key of the node.
  • Asymmetric encryption is used to provide digital signatures, which enables participants in a transaction to confirm other participants in the transaction and the validity of the transaction. For example, a node can digitally sign a message, and another node can confirm that the message was sent by the node based on the digital signature of participant A. Digital signatures can also be used to ensure that messages are not tampered with during transmission. For example, refer to Figure 1 again. Participant A will send a message to participant B. Participant A generates a hash value of the message, and then uses its private key to encrypt the hash value to generate a digital signature. Participant A attaches the digital signature to the message, and sends the message with the digital signature to participant B.
  • Participant B uses the public key of participant A to decrypt the digital signature, thereby decrypting the corresponding hash value. Participant B hashes the received message to obtain another hash value, and then compares the two hash values. If the hash value is the same, participant B can confirm that the message is indeed from participant A and has not been tampered with.
  • the embodiments of this specification can also be applied to other block chain scenarios.
  • the embodiments of this specification can also be applied to a blockchain-like system.
  • data can be stored in the same block-chain structure.
  • the block-chain data stored in the block-chain structure does not need After consensus processing.
  • the “bottom block chain layer” refers to the lowermost block chain layer of the multi-layer block chain structure
  • the “upper block chain layer” refers to the block except the bottom layer in the multi-layer structure.
  • the “block chain layer” includes the bottom block chain layer and each upper block chain layer.
  • Bottom block refers to the block in the bottom block chain layer
  • upper block refers to the block in each upper block chain layer.
  • “Adjacent upper block chain layer” refers to the adjacent "upper layer block.
  • “Lower layer” refers to the "next layer”, for example, "lower block” refers to the next layer of a block chain layer. Blocks in the chain layer.
  • the “base block” refers to the block in each block chain layer that meets the predetermined conditions and triggers the generation of the corresponding upper block.
  • the “previous benchmark block” refers to the block in the same block chain layer.
  • the previous reference block in the “reference block”, for example, the “reference block” and “previous reference block” in the “previous reference block of the reference block” refer to adjacent reference blocks in the same block chain layer
  • Previous block or “next block” refers to the previous block or the next block of a block in the verification path mentioned in this manual. This block is or The latter block may be located in the same block chain layer or in a different block chain layer.
  • “Block height” refers to the position of the block in the corresponding block chain layer.
  • each block chain layer is defined The block height of the first block of the layer is 0, then the block height of the third block of the block chain layer can be 2. Similarly, if the block height of the first block of each block chain layer is defined If the height is 1, the block height of the third block of the block chain layer can be 3.
  • the block height can be determined in any orderly manner, as long as each block can be located in the corresponding block chain layer based on the block height The location is fine.
  • Fig. 3 is a flowchart of a method for generating a multi-layer block chain structure according to an embodiment of the present specification.
  • the bottom block of the bottom block chain layer of the multi-layer block chain structure is generated based on the transaction data.
  • the underlying block of the underlying block chain layer can be generated by any method that generates a block chain structure. For example, it can be generated using the block chain generation method described above with reference to Figures 1 and 2, or using blocks such as Bitcoin and Ethereum. Chain generation method to generate.
  • Each transaction data can be packaged into the underlying block after the consensus processing of each blockchain node and the smart contract execution processing. In a blockchain-like system, the transaction data on the chain can be processed without consensus.
  • the reference block in each block chain layer is a block corresponding to each block in the upper block chain layer.
  • the reference block can be determined based on whether the number of blocks between each block in the underlying block chain layer and the previous reference block reaches a specified number, and it can also be based on the number of blocks in the underlying block chain layer. Whether the time interval between the generation time and the generation time of the previous reference block reaches the specified time interval to determine the reference block. In this specification, when determining the number of blocks between a block and another block, the other block is included.
  • the upper block is generated based at least in part on the block information of the reference block The corresponding upper block of the chain layer.
  • the multi-layer block chain structure may have an upper block chain layer, and may also include a plurality of upper block chain layers.
  • a multi-layer block chain structure has multiple upper block chain layers, after the bottom block chain layer is generated based on the bottom block chain layer, the same way can also be used for each upper block chain layer, successively based on The upper block chain layer generates an adjacent upper block chain layer.
  • each upper block chain layer it can be determined whether the upper block chain layer has a reference block that triggers the generation condition of the upper block chain layer.
  • the adjacent upper block chain layer of the upper block chain layer is generated based at least in part on the block information of the reference block. The following describes the generation process of the multi-layer block chain structure with reference to FIG. 4.
  • Fig. 4 is a schematic diagram of a multi-layer block chain structure according to an embodiment of the present specification.
  • Four block chain layers are schematically shown in FIG. 4, but the embodiment of this specification does not limit the number of block chain layers.
  • B ij represents the j-th block of the i-th block chain layer, for example, B 11 represents the first block of the first block chain layer (ie, the underlying block chain layer), and B 22 Represents the second block of the second block chain layer (that is, the first upper block chain layer).
  • B 11 is the genesis block, which refers to the first block of the underlying blockchain layer.
  • blocks B 12 to B 111 of the underlying block chain layer are sequentially generated.
  • Each upper block chain layer is generated based on the lower block chain layer of the upper block chain layer.
  • the first upper block chain layer is generated based on the bottom block chain layer
  • the second upper block chain layer is generated based on the first upper block chain layer.
  • the first block of each upper block chain layer can be called a header block (for example, header blocks B 21 , B 31 , B 41 ).
  • the first block of each blockchain layer can be determined as the first reference block of the blockchain layer (for example, blocks B 11 , B 21 , B 31 ), and then based on the reference block The block generates the header block of the upper block chain layer of the block chain layer (for example, blocks B 21 , B 31 , B 41 ).
  • the header block of the upper block chain layer may include the hash value of the first block of the lower block chain layer of the upper block chain layer.
  • the header block of each upper blockchain layer may also be generated based on the genesis block.
  • the header block of each upper blockchain layer may include the hash value of the genesis block.
  • the genesis block can be copied to generate the header block of the upper block chain layer.
  • Figure 4 shows a situation where the header blocks of each upper block chain layer correspond to the genesis block
  • the block chain layer can be compared with the block chain layer.
  • the number of blocks between the first block reaches the specified number of blocks or the time interval between the generation time and the generation time of the first block reaches the specified time interval is determined as the first block chain layer.
  • a benchmark block For example, the example shown in FIG. 4 can be simply modified as follows, that is, each upper block chain layer may not include the blocks B 21 , B 31 , and B 41 shown in FIG. B 22 , B 32 , and B 42 are used as the first block.
  • the block B 13 of the bottom block chain layer can be determined as the first reference block of the bottom block chain layer, and then the first upper zone of the first upper block chain layer can be generated based on B 13 Piece.
  • the first upper block of each upper block chain layer can include the hash value of the genesis block to quickly locate from the bottom block chain layer to each upper block chain layer, or from each The upper block chain layer is positioned to the bottom block chain layer.
  • the number of blocks from the previous reference block can reach the specified number or the interval between the generation time and the generation time of the previous reference block can reach Specify the time interval as the trigger condition to determine other reference blocks of each block chain layer.
  • the process described below with reference to FIG. 5A to FIG. 6B may be used to determine each reference block of each blockchain layer, and generate an upper layer block corresponding to the determined reference block.
  • the generation of each block chain layer can be executed in parallel in real time, or after each block of the underlying block chain layer is generated, according to the system's computing resource occupancy, each upper block chain layer generated at the right time .
  • 5A and 5B show an example in which the upper block chain layer is generated asynchronously with the lower block chain layer.
  • traverse the blocks in the block chain layer that have not performed the benchmark block determination process that is, query one by one
  • Each block is used to determine whether the currently queried block is a reference block that triggers the generation conditions of the upper block chain layer.
  • the corresponding upper block adjacent to the upper block chain layer can be generated. For example, after each low-level block is generated, each generated low-level block may be traversed at a suitable time period to determine the reference block that triggers the generation of the upper-level block in the first upper-level block chain layer.
  • Fig. 5A is a flowchart of a reference block determination process in a method for generating a multi-layer block chain structure according to an embodiment of the present specification.
  • the number of blocks between the currently queried block and the previous reference block of the block chain layer is determined. Then in block 5A04, it is determined whether the number of blocks between the currently queried block and the previous reference block reaches the specified number.
  • the block between a block and another block includes the other block. Accordingly, when referring to the number of blocks between a block and another block, the The other block is included.
  • the block between B 11 and B 13 includes B 12 and B 13 , and accordingly, the number of blocks between B 11 and B 13 is 2.
  • the currently queried block is determined as the reference block.
  • the number of blocks between the reference blocks of each block chain layer can be set. For example, for the example in FIG. 4, the number of blocks between a reference block and the previous reference block can be 2. If the number of blocks between the currently queried block and the previous reference block reaches the set specified number, the currently queried block can be determined as the reference block.
  • block 5A08 If the number of blocks between the currently queried block and the previous reference block does not reach the specified number, in block 5A08, the next block of the blockchain layer is regarded as the current queried block, and the above is executed again process.
  • FIG. 5B is another example flowchart of the reference block determination process in the method for generating a multi-layer block chain structure according to an embodiment of the present specification.
  • the time interval between the current inquired block of the block chain layer and the generation time of the previous reference block is determined.
  • the generation time of each block can be determined based on the timestamp of the block, for example.
  • the currently queried block is determined as the reference block. If the determined time interval does not reach the specified time interval, in block 5B08, the next block of the block chain layer is regarded as the currently queried block, and the above process is executed again.
  • FIGS. 6A and 6B show an example in which the upper block chain layer is generated in synchronization with the lower block chain layer. It is possible to monitor the blocks in each block chain layer. When a new block is added to each block chain layer, it is determined whether the new block is a reference block that triggers the generation conditions of the upper block chain layer. For full nodes, the newly added block can be a newly generated block, and for light nodes, the newly added block can also be a block obtained from the full node. Each block at the lightweight node may only include the block header. Lightweight nodes can locally generate upper-level block chain layers and upper-level blocks, and can also obtain upper-level block chain layers from all nodes.
  • Fig. 6A is another example flowchart of a reference block determination process in a method for generating a multi-layer block chain structure according to an embodiment of the present specification.
  • each block chain layer is monitored to see if there are new blocks added.
  • block 6A08 When a new block is added to a certain block chain layer, in block 6A08, the number of blocks between the new block and the previous reference block is determined. Then, in block 6A10, it is judged whether the determined number of blocks has reached the specified number.
  • the new block is the reference block of the corresponding block chain layer. If the determined number of blocks does not reach the specified number, then continue to monitor the block chain layer.
  • FIG. 6B is another example flowchart of the reference block determination process in the method for generating a multi-layer block chain structure according to an embodiment of the present specification.
  • each block chain layer is monitored to see if there is a new block generated.
  • the new block is the reference block of the corresponding block chain layer. If the determined time interval does not reach the specified time interval, then continue to monitor the block chain layer.
  • the reference block of the bottom block chain layer is B 11 , B 13 , B 15, etc.
  • the reference block of the first upper block chain layer is B 21 , B 23 , B 25, etc.
  • the reference block of the second upper block chain layer is B 31 , B 33 and so on.
  • the reference block when the reference block is determined based on whether the number of blocks between the previous reference block and the previous reference block reaches the specified number, two adjacent reference blocks of the same block chain layer
  • the number of blocks before the block can be the same or different, and the designated number corresponding to each block chain layer can be the same or different.
  • the generation time interval before two adjacent reference blocks of the same block chain layer may be the same or different.
  • Each block chain layer corresponds to The specified time interval can be the same or different.
  • the specified number or specified time interval corresponding to each reference block of each block chain layer can be made the same, or for each block chain layer, each reference block of the block chain layer can be made to correspond to The specified number or specified time interval are the same.
  • the designated number or designated time interval corresponding to each reference block of the block chain layer can also be determined based on a predetermined rule. For example, the number of blocks between adjacent reference blocks of each block chain layer can be increased in an arithmetic sequence. As a result, based on the specified number or specified time interval corresponding to each reference block, rapid positioning between each block chain layer can be realized.
  • the upper layer of the block chain layer can be generated based on the block information of at least some of the blocks from the first block of the block chain layer to the reference block
  • the corresponding block of the block chain layer For the underlying block chain layer, the first block is the genesis block, and for each upper block chain layer, the first block is the head block of the corresponding upper block chain layer.
  • the block information can be the hash value of each block or the content of the block, or part of the content of the block (such as the hash value and timestamp of the block or the hash of the parent block of the block) Value and the hash value of the block). In this way, each block chain layer can be linked to the corresponding lower block chain layer, and link verification can be performed based on the corresponding block information.
  • the generated upper-level block may include the hash value of the reference block.
  • the block B 22 of the first upper block chaining layer may include the hash value of the reference block B 13.
  • the block content of all blocks from the first block of the block chain layer to the reference block can be hashed to obtain the hash value, and the The upper block corresponding to the reference block includes the hash value.
  • the block content of all blocks from B 11 to B 15 may be hashed to obtain a hash value, and then block B 23 may include the hash value.
  • the hash value of all blocks from the first block of the block chain layer to the reference block can be hashed to obtain the hash value, and The upper block corresponding to the reference block includes the hash value.
  • the hash value of all blocks from B 11 to B 15 may be hashed to obtain a hash value, and then block B 23 may include the hash value.
  • the first block of the block chain layer and the block content or hash value of the reference block can also be hashed to obtain the hash value, and use The block corresponding to the upper block chain layer of the reference block includes the hash value.
  • the block content or hash value of B 11 and B 15 can be hashed to obtain the hash value, and then the upper block generated by B 15 B 23 includes the hash value.
  • the upper-level block generated corresponding to the corresponding reference block may also include multiple hash values determined using the above example.
  • the blocks of the upper block chain layer generated by the respective reference blocks of each block chain layer may also have block attributes with a known block chain structure.
  • the upper block of each upper block chain layer may include the hash value of the previous upper block (parent block) of the upper block.
  • the block index information of the reference block and the corresponding upper block can also be stored.
  • Block index information helps to locate between each block chain layer.
  • the block index information may be, for example, the block height of the reference block or the upper block corresponding to the reference block.
  • the block index information can be included in the reference block.
  • the reference block can include fields that do not participate in the hash value operation of the reference block. After the corresponding upper block is generated, the block height of the upper block can be Write this field.
  • the block index information can be included in the upper block corresponding to the reference block.
  • the block header of the upper layer block may include a reference block block height field, and when the corresponding upper layer block is generated, the block height of the corresponding reference block is written into the reference block block height field.
  • the block index information may also be included in the next block of the upper block corresponding to the reference block.
  • the block height of the reference block of the upper block may be written into the block header of the next block.
  • an index database can also be set.
  • the block index information of the upper block and the reference block can be stored in the index database.
  • Fig. 7 is a flowchart of a method for updating trust points in a multi-layer block chain structure according to an embodiment of the present specification.
  • the trust point indicates the verified bottom block with the largest block height in the bottom block chain layer.
  • the trust point means that among the underlying blocks stored at the node, from the genesis block to the underlying blocks indicated by the trust point have all been verified, that is, these underlying blocks are trusted blocks.
  • the initial value of the trust point can be the genesis block. For example, for a lightweight node that has never performed block verification, the trust point points to the genesis block.
  • the trust point can be stored at the lightweight node.
  • the lightweight node can update the trust point to point to the highest verified underlying block of the current block, for example, in the trust point field Store the block height or hash value of the verified underlying block with the largest current block height.
  • the trust point when the lightweight node performs SPV verification for the transaction to be verified, if the underlying block of the transaction to be verified is located before the trust point (that is, the underlying block is a verified and trusted underlying block ), the existence of the transaction to be verified can be proved, and after the verification of the existence proof is passed, it is determined that the transaction to be verified has been executed correctly.
  • the verification path between the verified underlying block and the target underlying block indicated by the current trust point is determined.
  • Lightweight nodes can obtain each block chain layer block between the verified block indicated by the current trust point and the target underlying block from the full node when the trust point needs to be updated, and add the obtained block to In each local block chain layer. Then, the lightweight node can determine the verification path based on the locally stored multi-layer block chain structure.
  • the current trust point can point to the block B 14 of the underlying blockchain layer.
  • the target bottom layer block can be, for example, B 112 in FIG. 4.
  • the trust point can be updated when the SPV verification of the transaction to be verified is performed, and the target underlying block can be determined based on the underlying block to be verified where the transaction to be verified is located.
  • Fig. 8 is a flowchart of a method for performing SPV verification on a transaction to be verified according to an embodiment of the present specification.
  • the underlying block to be verified where the transaction to be verified is located is determined.
  • a lightweight node wants to know whether a transaction is executed correctly, it can obtain the underlying block of the transaction from the full node.
  • the full node can send the block height of the underlying block of the exchange to the light node.
  • the lightweight node can perform SPV verification on the transaction.
  • SPV verification can include correctness verification and existence verification (or called existence proof). Correctness verification can be performed by verifying the integrity of the link from the genesis block to the underlying block to be verified, and is used to prove that the transaction to be verified is correct.
  • Existence verification is used to prove that the transaction to be verified does exist in the block to be verified, and can be performed based on any existence proof method. For example, it is possible to obtain the query path of the transaction to be verified in the MPT tree based on the MPT tree, and to verify whether the transaction tree root hash is consistent with the transaction tree root hash in the block header based on the obtained data nodes of each MPT tree in the query path When the two are consistent, it can be determined that the transaction to be verified does exist in the underlying block to be verified.
  • the bottom layer block to be verified is determined, in block 804, it is determined whether the bottom layer block to be verified is located before the trust point. That is, it is determined whether the underlying block to be verified is a trusted underlying block. It can be determined by comparing the block height of the block to be verified with the block height of the verified underlying block pointed to by the trust point to determine whether the transaction to be verified is located before the trust point.
  • the existence proof of the transaction to be verified can be performed, and at block 810, it is determined whether the existence proof is passed.
  • the trust point update method described in the embodiment of this specification can be used to update the trust point to a target underlying block whose block height is not less than the underlying block to be verified .
  • any underlying block whose block height is not less than the underlying block where the transaction to be verified is located can be used as the target underlying block.
  • proof of existence it can be determined in block 812 that the transaction to be verified has been executed correctly. If the proof of existence is not passed, it can be determined in block 814 that the transaction to be verified was not executed correctly.
  • the verification path refers to the path from the current trust point to the target underlying block.
  • the verification path can go through any blockchain layer.
  • the verification path from the current trust point TP to the target underlying block B 112 can be B 15 ⁇ B 23 ⁇ B 32 ⁇ B 33 ⁇ B 25 ⁇ B 26 ⁇ B 111 ⁇ B 112 .
  • the verification path can be determined only via the underlying block chain layer, or via at least one upper block chain layer. Since there is at least one block between two adjacent reference blocks of each block chain layer, the upper block of the block chain layer is equivalent to "skipping" the spaced block. Thus, when the verification path is determined via at least one upper block chain layer, the number of blocks in the verification path can be reduced, thereby improving the verification efficiency.
  • the shortest path (that is, the path with the least number of blocks) can be selected as the verification path from all the paths between the verified bottom-level block pointed to by the current trust point and the target bottom-level block.
  • the verification path When the verification path is determined via the upper block chain layer, there is a path loss when rising from each block chain layer to the upper block chain layer or descending from the upper block chain layer to the lower block chain layer. That is, due to the ascent or descent between the blockchain layers, the number of blocks through which the path passes may increase. Therefore, when the number of blocks between the verified bottom-layer block indicated by the current trust point and the target bottom-layer block is small, if the upper-layer block chain layer is passed, the verification path may be more than determined by the bottom-layer block chain layer. The verification path must be long. Therefore, in an example, when there are at least two underlying reference blocks before the verified underlying block and the target underlying block indicated by the current trust point, the verification path can be determined via at least one upper block chain layer.
  • the number of underlying blocks between the determined target underlying block and the verified underlying block indicated by the current trust point may be greater than the first predetermined number. Therefore, the number of bottom-layer blocks between the target bottom-layer block and the verified bottom-layer block pointed to by the current trust point is large enough, so that the verification path can be determined through at least one upper-level block chain layer each time the trust point is updated. .
  • the number of underlying blocks between the target underlying block and the verified underlying block indicated by the current trust point is greater than the second predetermined number (the second predetermined number is not less than the first predetermined number)
  • multiple upper blockchains can be used
  • the formula layer determines the verification path, so that the number of blocks included in the verification path can be reduced as much as possible to improve the verification efficiency.
  • the verification path can be determined based on the first block number and the second block number.
  • the first block number is the number of blocks between two adjacent reference blocks of each block chain layer
  • the second block number is The number of bottom-level blocks between the target bottom-level block and the verified bottom-level block.
  • the same number of blocks may exist between two adjacent reference blocks in each block chain layer, that is, the number of first blocks between two adjacent reference blocks is the same.
  • the number of first blocks is N
  • the number of underlying blocks existing between two adjacent blocks in the L-th block chain layer is N L-1.
  • there are 2 2-1 bottom-level blocks between adjacent two blocks in the second block-chain layer ie, the first upper-level block-chain layer.
  • the ascending point of the blockchain layer through which the verification path passes can be determined based on the first block number and the second block number. For each block passed by the verification path, if the next block of the block is adjacent The upper block chain layer is called the rising point.
  • the sequence number of the block corresponding to the rising point of the L-th block-chain layer in the L-th block-chain layer is (% represents the remainder operation):
  • B LX is the first block of the L-th blockchain layer in the verification path.
  • the rising point is 3+[2-(3-1)%2]%2
  • the calculation result is 3, that is, the value of X is 3, so the third block B 23 in the second block chain layer is the rising point.
  • the drop point of each block chain layer passed by the verification path can also be determined based on the first block number and the second block number. For each block passed by the verification path, if the next block of the block is a block of the lower block chain layer, the block is called a drop point. Assume that the verified block indicated by the current trust point is B 1j (the jth block of the underlying blockchain layer), and the target bottom block is B 1k (the kth block of the underlying blockchain layer). Then the sequence number of the block corresponding to the descending point in the L-th block chain layer is:
  • the block is determined as the falling point (such as B 33 ).
  • the blocks between the ascending point and the falling point in the block chain layer are all blocks in the verification path.
  • the determined rising points are B 15 and B 23 respectively
  • the falling points are B 33 and B 26 respectively .
  • the verification path B 15 ⁇ B 23 ⁇ B 32 ⁇ B 33 ⁇ B 25 ⁇ B 26 ⁇ B 111 ⁇ B 112 determined by the above embodiment includes 8 blocks.
  • the determined verification path will be B 15 ⁇ B 23 ⁇ B 24 ⁇ B 25 ⁇ B 26 ⁇ B 111 ⁇ B 112 , the verification path includes 7 areas Piece. That is, the verification path is shortened compared to the case when the number of blockchain layers passed exceeds the number of blocks in the first interval.
  • the first block number can be determined based on block index information. Since the block index information includes the index relationship between the reference block and the corresponding upper block, the block chain layer between the verified bottom block and the target bottom block can be determined based on the block index information And determine the number of the first block between two adjacent reference blocks in each layer of the block chain layer. After the first block number is confirmed, when the verification path is determined through the upper block chain layer, it can be based on the first block number between two adjacent reference blocks and the verified bottom block and the target bottom zone. The second number of blocks between blocks is calculated and the blocks of each layer of the block chain layer should be included in the verification path.
  • the verification path can also be determined based on the block index information.
  • the block index information indicates the distance between each reference block and the corresponding upper-level block. index.
  • the reference block in each block chain layer can be determined based on the block index, and then after rising to each upper block chain layer, the next block of the block chain layer can be determined by heuristics. Reach or exceed the target underlying block. If it reaches or exceeds the underlying block, then discard the block chain layer and descend to the lower block chain layer to continue searching.
  • the block index information stores the index relationship between each reference block and the corresponding upper block, it can be determined based on the block index information whether each upper block in the upper block chain layer has actually exceeded the target The bottom layer.
  • the block index information may be included in each reference block, and each reference block may include an upper block index field.
  • the block height or hash value of the upper block corresponding to the reference block may be written Enter the upper block index field of the reference block.
  • the upper block index field of the queried block When the upper block index field of the queried block is empty, it indicates that the queried block is not the corresponding block chain When the index field of the upper layer block is not empty, it indicates that the queried block is a reference block.
  • the upper-layer block corresponding to the queried block can be determined based on the upper-layer block index information, and then ascending to the adjacent upper-layer block chain layer to continue the query.
  • the index of determines whether the bottom-layer block that the upper-layer block can locate has exceeded the target bottom-layer block.
  • the target bottom block If it does not exceed the target bottom block, it can continue to rise to the upper block chain layer, if it exceeds the target bottom block, it will fall back to the previous upper block of the upper block chain layer and drop to the lower block chain. Floor. After descending to the lower block chain layer of the upper block chain layer, if the lower block chain layer is still the upper block chain layer, you can continue to determine whether the next block of the lower block that has fallen to exceeds Target bottom block. If the next block does not exceed the target bottom block, the next block of the bottom block can be determined as the block in the verification path. If the next block of the lower-level block has exceeded the target bottom-level block, it will continue to descend until it reaches the bottom-level blockchain. Perform the above process until the target underlying block is queried to determine the verification path.
  • each block in the verification path it is verified whether the link between the block and the previous block is correct.
  • the link verification process can be determined based on the link relationship between each block.
  • each block stores the parent hash, so the chain between each block and the previous block can be verified based on the block information of the previous block Is the path correct?
  • B 14 and B 15 , B 32 and B 33 are located at the bottom block chain layer and the second upper block chain layer, respectively, B 14 is the B 15
  • B 32 is the parent block of B 33.
  • a block may be based on the information in the hash and the parent B 15 B 14 to verify the link between B 14 and B 15 are correct.
  • the block information of the corresponding reference block can be used to verify the relationship between the two adjacent blocks The link is correct.
  • B 15 and B 23, B 32 are located at different layers of the chain block, B 15 is the reference block B 23, B 23 B 32 of the block is the reference.
  • B 32 is block information based on at least B 23 is generated, and thus the information may be based on the block B 15 and B 23 to B 15 and verified prior to B 23 link, based on information of the block B 23 and B 32 to verify that the link prior to B 23 and B 32.
  • the specific link verification process will be described below with reference to FIG. 9.
  • the verification process of the link between each block in the verification path may be executed after the verification path is determined, or may be executed during the process of determining the verification path. For example, for the verification path shown in Figure 4, when determining the next block of B 14 (ie B 15 ), verify the link between B 14 and B 15 and then determine the next block of B 15 . After determining the next block of B 15 (ie, B 23 ), the link between B 15 and B 23 is verified. In the process of determining the verification path and the link verification process, when the link before any two blocks is incorrect, it can be determined that the link in the verification path is incorrect.
  • Each block in the verification path may store a first hash value generated at least based on block information of the previous block. If the previous block of the block is in the same block chain layer as the block, the first hash value may be the parent hash of the block. If the previous block of the block and the block are in different block chain layers, the first hash value may be obtained by performing a hash operation based at least in part on the block information of the previous block. At this time, the example shown in FIG. 9 can be used for link verification.
  • Fig. 9 is a flowchart of a link verification process in a method for updating a trust point in a blockchain according to an embodiment of the present specification.
  • a hash operation is performed based on at least the block information of the previous block to obtain a second hash value. Then, in block 904, it is determined whether the obtained second hash value is consistent with the first hash value in the block. When the two are consistent, at block 906, it is determined that the link between the block and the previous block is correct. When the two are inconsistent, at block 908, it is determined that the link between the block and the previous block is incorrect.
  • the block header of the previous block can be hashed to obtain the second hash value. Then, the consistency of the second hash value and the parent hash in the block can be compared. For example, taking the verification path indicated by the solid arrow in Figure 4 as an example, since B 14 is the parent block of B 15 , the block information of B 14 can be hashed to obtain the hash value and compare all The obtained hash value is consistent with the parent hash stored in B 15. When the two are consistent, it can be determined that the link between B 14 and B 15 is correct.
  • the previous block is the reference block of the block, so it can be performed based at least in part on the block information of the previous block Hash operation to obtain the second hash value.
  • the upper block may include the hash value of the corresponding reference block.
  • the block information of the previous block can be hashed to obtain the second hash value. Taking B 15 and B 23 in the verification path shown in FIG. 4 as an example, the block header of B 15 may be hashed to obtain the second hash value.
  • the block information from the first block to the reference block in the block chain layer where the reference block is located can be performed. Hash operation, and store the obtained hash value as the first hash value in the generated upper block.
  • the first block in the block chain layer where the previous block is located can be compared to the previous block. All block information of the block is hashed to obtain the second hash value.
  • the block information of B 11 , B 12 , B 13 , B 14 and B 15 can be hashed to obtain the second hash value . Then, the obtained hash value can be compared with the first hash value stored in B 23 , and if the two are consistent, it can be determined that the link between B 15 and B 23 is correct.
  • Fig. 10 is a flowchart of a method for updating trust points in a blockchain according to another embodiment of the present specification.
  • the verification path between the verified underlying block and the target underlying block indicated by the current trust point is determined.
  • the verification path is determined, in block 1004, for each block in the verification path, it is verified whether the link between the block and the previous block of the block is correct. Then in block 1006, it is judged whether the links between each block in the verification path are all verified as correct.
  • block 1008 it is determined whether the target underlying block is correct. You can refer to the example shown in FIG. 11 to verify whether the target underlying block is correct.
  • Fig. 11 is a flowchart of a target underlying block verification process in a method for updating trust points in a multi-layer block chain structure according to an embodiment of the present specification.
  • multiple target bottom-level block information of the target bottom-level block is obtained from multiple full nodes in the blockchain system.
  • block 1104 when there is no less than a statutory number of consistent target bottom-layer block information in the multiple target bottom-layer block information, it is determined that the target bottom-layer block is correct.
  • a statutory number of consistent target bottom-level block information it can be determined that the target bottom-level block has passed the consensus of the entire network, and thus it can be determined that it is correct.
  • the trust point is updated to indicate the target underlying block. If the link between each block of the verification path and the previous block is not completely correct or the target underlying block is determined to be incorrect, it indicates that the target underlying block cannot be trusted. In this case, the target underlying block can be re-determined and the trust point update process can be performed.
  • the block can be sent to a trusted third-party server.
  • the three-party server can use its private key to sign and authenticate the block.
  • you can obtain the signature of the target underlying block from the third-party server, and then use the public key of the third-party server to verify the signature of the obtained target underlying block. Make sure that the target underlying block is correct.
  • FIG. 12 is a structural block diagram of a device for generating a multi-layer block chain structure according to an embodiment of the present specification.
  • the multi-layer block chain structure generating device 1200 includes a bottom block chain layer generating unit 1210 and an upper block chain layer generating unit 1220.
  • the bottom block chain layer generating unit 1210 generates blocks of the bottom block chain layer in the multi-layer structure based on the transaction data.
  • the upper block chain layer generating unit 1220 generates the upper block chain layer based on the lower block chain layer according to the upper block chain layer generation conditions.
  • the upper block chain layer generating unit 1220 includes a reference block determining module 1221 and an upper block chain layer generating module 1222.
  • the reference block determination module 1221 determines whether there is a reference block that triggers the generation condition of the upper block chain layer in the underlying block chain layer.
  • the upper block chain layer generation condition may include the number of blocks between the reference block and the previous reference block reaching a specified number, and may also include the generation time of the reference block and the generation time of the previous reference block The time interval reaches the specified time interval.
  • the reference block determination module 1221 may traverse the blocks in each block chain layer in the multi-layer block chain structure to determine the reference block that meets the generation conditions of the upper block chain layer. In another example, the reference block determination module 1221 may determine whether the newly generated block is a reference block that meets the generation conditions of the upper block chain layer for each block chain layer in the blockchain.
  • the upper block chain layer generation module 1222 responds to the presence of a reference block in the lower block chain layer that triggers the block generation condition of the upper block chain layer, and generates the upper block chain layer based at least in part on the block information of the reference block. The corresponding upper block of the layer.
  • the multi-layer block chain structure may include a plurality of upper block chain layers.
  • the upper block chain layer generating unit 1220 can generate the upper block chain layer based on the upper block chain layer according to the same or different upper block chain layer generation conditions for each upper block chain layer.
  • the adjacent upper block chain layer may determine whether there is a reference block in the upper block chain layer that triggers the generation condition of the upper block chain layer for each upper block chain layer.
  • the upper block chain layer generation module 1222 may generate the adjacent upper block of the upper block chain layer based at least in part on the block information of the reference block The corresponding upper block of the chain layer.
  • the upper block chain layer generation module 1222 may also generate the block information based on the block information of at least part of all blocks from the first block of each block chain layer to the reference block. The corresponding block of the adjacent upper block chain layer of the block chain layer.
  • the block chain generation device may also include a block index information storage unit (not shown in the drawings).
  • the block index information storage unit stores the block index information of the reference block and the corresponding upper block.
  • the block index information storage unit may store the block index information in the reference block or the upper block corresponding to the reference block, and may also store the block index information in the next block of the upper block. Block.
  • the block index information storage unit may also store the block index information in the index database.
  • Fig. 13 is a structural block diagram of an apparatus for updating trust points in a multi-layer block chain structure according to an embodiment of the present specification.
  • the trust point update device 1300 includes a verification path determination unit 1310, a link verification unit 1320, a target bottom layer block verification unit 1330, and a trust point update unit 1340.
  • the verification path determination unit 1310 determines the verification path between the verified bottom-level block and the target bottom-level block indicated by the current trust point based on the multi-layer block chain structure. In one example, the verification path determination unit 1310 may determine the verification path via at least one upper-level block chain layer when there are at least two base-level block-chain-type reference blocks between the target bottom-level block and the verified bottom-level block. .
  • the number of first blocks between two adjacent reference blocks in each block chain layer may be equal, and the number of upper block chain layers passed by the verification path may not exceed the first zone Number of blocks.
  • the verification path determination unit 1310 may determine the verification path based on the first block number and the second block number, where the first block number is the difference between two adjacent reference blocks of each block chain layer.
  • Block number, the second block number is the number of blocks between the target bottom block and the verified bottom block.
  • the number of first interval blocks between two adjacent reference blocks of each block chain layer may be determined based on block index information.
  • the verification path determination unit 1310 may also determine the verification path based on block index information.
  • the link verification unit 1320 verifies whether the link between the block and the previous block in the verification path is correct for each block in the verification path.
  • the target bottom block verification unit 1330 verifies whether the target bottom block is correct.
  • the trust point update unit 1340 updates the target bottom block as the trust point when the link between each block in the verification path is correct and the target block is correct.
  • the trust point update apparatus may not include the target underlying block verification unit 1330.
  • the trust point update unit 1340 may update the target underlying block to the trust point when the link between each block in the verification path is correct.
  • FIG. 14 is a structural block diagram of the link verification unit in the device for updating the trust point of the multi-layer block chain structure shown in FIG. 13.
  • the link verification unit 1320 includes a hash operation module 1321 and a link verification module 1322.
  • each block in the verification path includes the first hash value of the previous block.
  • the hash operation module 1321 performs a hash operation based at least in part on the block information of the previous block obtained locally to obtain the second hash value.
  • the link verification module 1322 verifies whether the link between the block and the previous block is correct based on the consistency between the second hash value and the first hash value.
  • FIG. 15 is a structural block diagram of a target bottom-level block verification unit in the device for updating trust points in a multi-layer block chain structure shown in FIG. 13.
  • the target bottom block verification unit 1330 includes a target bottom block information acquisition module 1331 and a target bottom block verification module 1332.
  • the target bottom block information acquisition module 1331 obtains multiple target bottom block information of the target bottom block from multiple full nodes in the blockchain system.
  • the target bottom block verification module 1332 determines whether the target bottom block is correct when there is no less than a statutory number of consistent target bottom block information in the multiple target bottom block information.
  • the multi-layer block chain structure generation device and the trust point update device in the embodiments of the present specification can be implemented by hardware, or can be implemented by software or a combination of hardware and software.
  • the various embodiments in this specification are described in a progressive manner, and the same or similar parts among the various embodiments are referred to each other.
  • the multi-layer block chain structure generation device and the trust point update device in the embodiments of the present specification can be implemented by hardware, or can be implemented by software or a combination of hardware and software. Taking software implementation as an example, as a logical device, it is formed by reading the corresponding computer program instructions in the memory into the memory by the processor of the device where it is located. In the embodiment of the present specification, the multi-layer block chain structure generating device and the trust point updating device can be realized by using a computing device, for example.
  • Fig. 16 is a structural block diagram of a computing device for implementing a blockchain generation method or a trust point update method according to an embodiment of the present specification.
  • the computing device 1600 includes a processor 1610, a memory 1620, a memory 1630, a communication interface 1640, and an internal bus 1660, and a processor 1610, a memory (for example, a non-volatile memory) 1620, a memory 1630, and a communication interface
  • the 1640 is connected together via a bus 1660.
  • the computing device 1600 may include at least one processor 1610 that executes at least one computer-readable instruction (ie, the aforementioned Elements implemented in software).
  • computer-executable instructions are stored in the memory 1620, which, when executed, cause at least one processor 1610 to: generate blocks of the underlying block chain layer in the multi-layer block chain structure based on transaction data; and according to The upper block chain layer generation conditions are based on the lower block chain layer to generate the upper block chain layer, wherein, according to the upper block chain layer generation conditions, the upper block chain layer is generated based on the bottom block chain layer including: determining the bottom block chain Whether there is a reference block that triggers the generation condition of the upper block chain layer in the type layer; in response to the presence of a reference block in the underlying block chain layer that triggers the generation condition of the upper block chain layer, the area based at least in part on the reference block Block information to generate the corresponding upper block of the upper block chain layer.
  • computer-executable instructions are stored in the memory 1620, which when executed, cause at least one processor 1610 to: based on a multi-layer block chain structure, determine the verified underlying block and target indicated by the current trust point The verification path between the underlying blocks; for each block in the verification path, verify whether the link between the block and the previous block of the block is correct; and when each of the verification paths When the links between the blocks are all correct, update the target bottom block as a trust point.
  • a program product such as a non-transitory machine-readable medium.
  • the non-transitory machine-readable medium may have instructions (that is, the above-mentioned elements implemented in the form of software), which when executed by a machine, cause the machine to execute the various embodiments of the embodiments of this specification.
  • a system or device equipped with a readable storage medium may be provided, and the software program code for realizing the function of any one of the above-mentioned embodiments is stored on the readable storage medium, and the computer or device of the system or device The processor reads and executes the instructions stored in the readable storage medium.
  • the program code itself read from the readable medium can implement the function of any one of the above embodiments, so the machine readable code and the readable storage medium storing the machine readable code constitute the present invention a part of.
  • Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tape, Volatile memory card and ROM.
  • the program code can be downloaded from the server computer or the cloud via the communication network.
  • the device structure described in the foregoing embodiments may be a physical structure or a logical structure, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, or may be implemented by multiple physical entities. Some components in independent devices are implemented together.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
  • Developing Agents For Electrophotography (AREA)
  • Tires In General (AREA)
  • Traffic Control Systems (AREA)

Abstract

一种用于生成多层块链式结构的方法,所述多层块链式结构包括底层块链式层和上层块链式层,所述方法包括:基于交易数据生成多层块链式结构中的底层块链式层的区块(320);以及根据上层块链式层生成条件,基于底层块链式层生成上层块链式层,其中,根据上层块链式层生成条件,基于底层块链式层生成上层块链式层包括:确定底层块链式层中是否存在触发上层块链式层生成条件的基准区块(340);响应于底层块链式层中存在触发上层块链式层生成条件的基准区块,至少部分地基于该基准区块的区块信息,生成上层块链式层的对应上层区块(360)。

Description

用于生成多层块链式结构的方法及装置 技术领域
本说明书实施例涉及区块链技术领域,具体地,涉及用于生成多层块链式结构的方法及装置。
背景技术
区块链网络是一种去中心化的、由多个节点参与的分布式数据存储系统。数据一旦被写入每个节点上的区块链,一方面,意味着数据在区块链网络中被公开,另一方面,写入区块链的数据也难以被删除与篡改。此外,在类区块链系统中,中心化设备也可以采用类似于区块链存储(可以视为中心化的区块链存储)的方式对数据进行存储。在本说明书中,诸如区块链系统和类区块链系统之类的,以块链方式存储数据的系统被称为块链式系统。
在块链式系统中,块链数据非常庞大,而且随着时间推移,数据量会不断增长。在传统的块链式结构中,如果想要对块链上存储的数据进行同步、验证或查询等操作时,数据访问量和运算量巨大。因此,亟需一种能够提高对块链数据的操作效率的技术。
发明内容
鉴于上述,本说明书实施例提供了一种用于生成多层块链式结构的方法及装置。利用该方法和装置能够生成具有多层结构的块链。
根据本说明书实施例的一个方面,提供了一种用于生成多层块链式结构的方法,所述多层块链式结构包括底层块链式层和上层块链式层,所述方法包括:基于交易数据生成多层块链式结构中的底层块链式层的区块;以及根据上层块链式层生成条件,基于底层块链式层生成上层块链式层,其中,根据上层块链式层生成条件,基于底层块链式层生成上层块链式层包括:确定底层块链式层中是否存在触发上层块链式层生成条件的基准区块;响应于底层块链式层中存在触发上层块链式层生成条件的基准区块,至少部分地基于该基准区块的区块信息,生成上层块链式层的对应上层区块。
可选的,在一个示例中,多层块链式结构包括多个上层块链式层,并且其中,所述方法还可以包括:针对各个上层块链式层,根据相同或者不同的上层块链式层生成条件,基于该上层块链式层生成该上层块链式层的相邻上层块链式层。
可选的,在一个示例中,上层块链式层生成条件可以包括:底层块链式层中的两个相邻基准区块之间的区块数目达到指定数目;或者底层块链式层中的两个相邻基准区块的生成时间间隔达到指定时间间隔。
可选的,在一个示例中,多层块链式结构中的各个块链式层中的指定数目或指定时间间隔可以是相同的或不同的,以及各个块链式层之间的指定数目或指定时间间隔可以是相同的或不同的。
可选的,在一个示例中,所述方法还可以包括:针对所述多层块链式结构中的各层块链式层,确定新生成的区块是否是满足上层块链式层生成条件的基准区块。
可选的,在一个示例中,至少部分地基于该基准区块,生成上层块链式层的对应上层区块可以包括:基于从各个块链式层的第一个区块到该基准区块的所有区块中的至少部分区块的区块信息,生成该块链式层的相邻上层块链式层的对应上层区块。
可选的,在一个示例中,所述方法还可以包括:存储基准区块与对应上层区块的区块索引信息。
可选的,在一个示例中,所述区块索引信息可以为基准区块或对应上层区块的块高。
可选的,在一个示例中,所述区块索引信息可以被包括在基准区块或对应上层区块中,或所述区块索引信息被存储在索引数据库中。
可选的,在一个示例中,所述多层块链式结构中的各个上层块链式层的头区块可以包括底层块链式层的创世区块的哈希值。
根据本说明书实施例的另一方面,还提供一种用于生成多层块链式结构的装置,所述多层块链式结构包括底层块链式层和上层块链式层,所述装置包括:底层块链式层生成单元,基于交易数据生成多层块链式结构中的底层块链式层的区块;以及上层块链式层生成单元,根据上层块链式层生成条件,基于底层块链式层生成上层块链式层,其中,所述上层块链式层生成单元包括:基准区块确定模块,确定底层块链式层中是否存在触发上层块链式层生成条件的基准区块;上层块链式层生成模块,响应于底层块链式层中存在触发上层块链式层区块生成条件的基准区块,至少部分地基于该基准区块的区块信息,生成上层块链式层的对应上层区块。
可选的,在一个示例中,多层块链式结构包括多个上层块链式层,并且其中,所述上层块链式层生成单元还针对各个上层块链式层,根据相同或者不同的上层块链式层生成条件,基于该上层块链式层生成该上层块链式层的相邻上层块链式层。
可选的,在一个示例中,上层块链式层生成条件可以包括:底层块链式层中的两个相邻基准区块之间的区块数目达到指定数目;或者底层块链式层中的两个相邻基准区块的生成时间间隔达到指定时间间隔。
可选的,在一个示例中,所述基准区块确定模块针对所述多层块链式结构中的各层块链式层,确定新生成的区块是否是满足上层块链式层生成条件的基准区块。
可选的,在一个示例中,所述上层块链式层生成模块可以基于从各个块链式层的第一个区块到该基准区块的所有区块中的至少部分区块的区块信息,生成该块链式层的相邻上层块链式层的对应上层区块。
可选的,在一个示例中,所述装置还可以包括:区块索引信息存储单元,存储基准区块与对应上层区块的区块索引信息。
可选的,在一个示例中,所述区块索引信息存储单元可以将所述区块索引信息存储在基准区块或对应上层区块中,或将所述区块索引信息存储在索引数据库中。
根据本说明书实施例的另一方面,还提供一种计算设备,包括:至少一个处理器;以及存储器,所述存储器存储指令,当所述指令被所述至少一个处理器执行时,使得所述至少一个处理器执行如上所述的方法。
根据本说明书实施例的另一方面,还提供一种非暂时性机器可读存储介质,其存储有可执行指令,所述指令当被执行时使得所述机器执行如上所述的方法。
利用本说明书实施例的方法和装置,通过在存在触发上层块链式层生成条件的基准区块时,至少部分地基于该基准区块的区块信息,生成上层块链式层的对应上层区块,从而能够生成多层块链式结构。利用多层块链式结构,在对块链式结构中的数据进行相关操作时,可以不必一一访问底层块链式层的各个区块,从而能够降低数据访问量和运算量,以提高操作效率。
附图说明
通过参照下面的附图,可以实现对于本说明书实施例内容的本质和优点的进一步理解。在附图中,类似组件或特征可以具有相同的附图标记。附图是用来提供对本发明实施例的进一步理解,并且构成说明书的一部分,与下面的具体实施方式一起用于解释本说明书实施例的实施例,但并不构成对本说明书实施例的实施例的限制。在附图中:
图1示出了可用于执行根据本说明书实施例的实施例的用于生成多层块链式结构的方法和用于更新多层块链式结构中的信任点的方法的环境的示例的示意图;
图2示出了执行根据本说明书实施例的实施例的用于生成多层块链式结构的方法和用于更新多层块链式结构中的信任点的方法的系统架构的示例的示意图;
图3是根据本说明书的一个实施例的用于生成多层块链式结构的方法的流程图;
图4是根据本说明书的一个实施例的多层块链式结构的示意图;
图5A是根据本说明书的一个实施例的用于生成多层块链式结构的方法中的基准区块确定过程的流程图;
图5B是根据本说明书的一个实施例的用于生成多层块链式结构的方法中的基准区块确定过程的一个示例流程图;
图6A是根据本说明书的一个实施例的用于生成多层块链式结构的方法中的基准区块确定过程的另一示例流程图;
图6B是根据本说明书的一个实施例的用于生成多层块链式结构的方法中的基准区块确定过程的另一示例流程图;
图7是根据本说明书的一个实施例的用于更新多层块链式结构中的信任点的方法的流程图;
图8是根据本说明书的一个实施例的用于更新多层块链式结构中的信任点的方法中的链路验证过程的流程图;
图9是根据本说明书的另一实施例的用于更新多层块链式结构中的信任点的方法的流程图;
图10是根据本说明书的一个实施例的用于更新多层块链式结构中的信任点的方法中的目标底层区块验证过程的流程图;
图11是根据本说明书的一个实施例的对待验证交易进行SPV验证的方法的流程图;
图12是根据本说明书的一个实施例的多层块链式结构生成装置的结构框图;
图13是根据本说明书的一个实施例的用于更新多层块链式结构中的信任点的装置的结构框图;
图14是图13所示的用于更新多层块链式结构中的信任点的装置中的链路验证单元的结构框图;
图15是图13所示的用于更新多层块链式结构中的信任点的装置中的目标底层区块验证单元的结构框图;以及
图16是根据本说明书的一个实施例的用于实现用于生成多层块链式结构的方法或用于更新多层块链式结构中的信任点的方法的计算设备的结构框图。
具体实施方式
以下将参考示例实施方式讨论本文描述的主题。应该理解,讨论这些实施方式只是为了使得本领域技术人员能够更好地理解从而实现本文描述的主题,并非是对权利要求书中所阐述的保护范围、适用性或者示例的限制。可以在不脱离本说明书实施例内容的保护范围的情况下,对所讨论的元素的功能和排列进行改变。各个示例可以根据需要,省略、替代或者添加各种过程或组件。另外,相对一些示例所描述的特征在其它例子中也可以进行组合。
如本文中使用的,术语“包括”及其变型表示开放的术语,含义是“包括但不限于”。术语“基于”表示“至少部分地基于”。术语“一个实施例”和“一实施例”表示“至少一个实施例”。术语“另一个实施例”表示“至少一个其他实施例”。术语“第一”、“第二”等可以指代不同的或相同的对象。下面可以包括其他的定义,无论是明确的还是隐含的。除非上下文中明确地指明,否则一个术语的定义在整个说明书中是一致的。
现在结合附图来描述本说明书实施例的用于生成多层块链式结构的方法及装置、用于更新多层块链式结构中的信任点的方法及装置。
区块链是一种按照时间顺序来将数据区块顺序相连组合而成的链式数据结构,并且以密码学方式保证数据区块不可篡改和不可伪造。区块链包括一个或多个区块。区块链中的每个区块通过包 括该区块链中紧接其之前的前一个区块的加密散列而链接到该前一个区块。每个区块还包括时间戳、该区块的加密哈希以及一个或多个交易(transaction)。对已经被区块链网络的节点验证的交易进行哈希处理并形成Merkle树。在Merkle树中,对叶节点处的数据进行哈希处理,并且针对Merkle树的每个分支,在该分支的根处级联该分支的所有哈希值。针对Merkle树执行上述处理,直到整个Merkle树的根节点。Merkle树的根节点存储代表该Merkle树中的所有数据的哈希值。当一个哈希值声称是Merkle树中存储的交易时,可以通过判断该哈希值是否与Merkle树的结构一致来进行快速验证。
区块链是用于存储交易的数据结构。区块链网络是用于管理、更新和维护一个或多个区块链结构的计算节点网络。如上所述,区块链网络可以包括公有区块链网络、私有区块链网络或联盟区块链网络。
在公有区块链网络中,共识过程由共识网络的节点控制。例如,在公有区块链网络中可以存在成千上万个实体协作处理,每个实体操作该公有区块链网络中的至少一个节点。因此,公有区块链网络可以被认为是参与实体的公有网络。在一些示例中,大多数实体(节点)必须按序对每个区块进行签名,并且将签名后的区块添加到区块链网络的区块链中。公有区块链网络的示例可以包括特定对等支付网络。此外,术语“区块链”不特别指代任何特定的区块链。
公有区块链网络支持公有交易。公有交易在公有区块链网络内的所有节点之间共享,并且存储在全局区块链中。全局区块链是指跨所有节点复制的区块链。为了达成共识(例如,同意向区块链添加区块),在公有区块链网络内实现共识协议。共识协议的示例包括但不限于:工作量证明(POW,proof-of-work),权益证明(POS,proof-of-stake)和权威证明(POA,proof-of-authority)。在本说明书实施例中,采用POW作为非限制性示例。
私有区块链网络被提供来用于特定实体。私有区块链网络中的各个节点的读写权限被严格控制。因此,私有区块链网络通常也称为许可网络,其对允许谁参与网络以及的网络参与水平(例如,仅在某些交易情形下)进行限制。在私有区块链网络中,可以使用各种类型的访问控制机制(例如,现有参与方对添加新实体进行投票,监管机构控制许可等)。
联盟区块链网络在参与实体之间是私有的。在联盟区块链网络中,共识过程由授权节点控制。例如,由若干个(例如,10个)实体(例如,金融机构,保险公司)组成的联盟可以操作联盟区块链网络,每个实体操作该联盟区块链网络中的至少一个节点。因此,联盟区块链网络可以被认为是参与实体的私有网络。在一些示例中,每个参与实体(节点)必须按序对每个区块进行签名,并将该区块添加到区块链。在一些示例中,可以由参与实体(节点)的子集(例如,至少7个实体)来对每个区块进行签名,并将该区块添加到区块链。
在本说明书实施例中参考联盟区块链网络来详细描述本说明书实施例的实施例。然而,可以预期,本说明书实施例的实施例可以在任何适合的区块链网络中实现。
区块链是防篡改的共享数字分类账,其在公有或私有对等网络中记录交易。分类账被分发到 网络中的所有成员节点,并且网络中发生的资产交易历史记录被永久记录在区块中。
共识机制确保分布式区块链网络中的所有网络节点按照相同的顺序执行交易,并且随后写入相同的分类账。共识模型旨在解决拜占庭问题。在拜占庭问题中,分布式区块链网络中的比如服务器或网络节点的组件可能会出现故障,或者故意向其他节点传播错误的信息。由于其他网络节点需要首先就哪个网络节点首先失败达成共识,从而其他网络节点很难将该组件声明失败并将其排除出区块链网络。
图1示出了可用于执行根据本说明书实施例的实施例的用于生成多层块链式结构的方法和用于更新区块链中的信任点的方法的环境100的示例的示意图。在一些示例中,环境100使得实体能够参与区块链网络102。如图1所示,环境100包括网络104、和计算设备/系统106、108。在一些示例中,网络104可以包括局域网(LAN),广域网(WAN),因特网或其组合,并且连接网站、用户设备(例如,计算设备)和后端系统。在一些示例中,可以通过有线和/或无线通信链路来访问网络104。在一些示例中,计算设备/系统106、108通过网络104相互通信,以及通过网络104实现与区块链网络102之间的通信,以及区块链网络102中的节点(或,节点设备)通过网络104来进行通信。通常,网络104表示一个或多个通信网络。在一些情况下,计算设备/系统106、108可以是云计算系统(未示出)的节点,或者每个计算设备/系统106、108可以是单独的云计算系统,其包括通过网络104互连的多个计算机并且用作分布式处理系统。
在所说明的示例中,计算设备/系统106、108中的每个可以包括能够参与作为区块链网络102中的节点的任何合适的计算系统。计算设备/系统的示例包括但不限于,服务器,台式计算机,笔记本电脑,平板电脑设备和智能手机等。在一些示例中,计算设备/系统106、108上可以安装有用于与区块链网络102交互的一个或多个计算机实现的服务。例如,计算设备/系统106可以上可以安装有第一实体(例如,用户A)的服务,比如,第一实体用于管理其与一个或多个其他实体(例如,其他用户)的交易的交易管理系统。计算设备/系统108可以上可以安装有第二实体(例如,用户B)的服务,比如,第二实体用于管理其与一个或多个其他实体(例如,其他用户)的交易的交易管理系统。在图1的示例中,区块链网络102被表示为节点的对等网络,并且计算设备/系统106、108分别作为参与区块链网络102的第一实体和第二实体的节点。
图2示出了执行根据本说明书实施例的实施例的用于生成多层块链式结构的方法和用于更新多层块链式结构中的信任点的方法的系统架构200的示例的示意图。系统架构200的示例包括分别与参与方A,参与方B和参与方C对应的参与方系统202、204、206。每个参与方(例如,用户,企业)参与被提供来作为对等网络的区块链网络212。区块链网络212包括多个节点214,其中,节点214中的至少一些节点在区块链216中记录信息,并且所记录的信息不可更改。尽管在区块链网络212内示意性地示出了单个区块链216,但是可以提供区块链216的多个副本,并且在区块链网络212中维护多个副本,如稍后详细描述的。
在所示出的示例中,每个参与方系统202、204、206分别由参与方A,参与方B和参与方C 提供,或者被提供来作为参与方A,参与方B和参与方C,并且充当区块链网络212内的对应节点214。如这里所使用的,节点通常是指连接到区块链网络212的单个系统(例如,计算机,服务器),并且使得相应的参与方能够参与区块链网络。在图2示出的示例中,参与方对应于每个节点214。然而,一个参与方可以操作区块链网络212内的多个节点214,和/或多个参与方可以共享单个节点214。在一些示例中,参与方系统202、204、206使用协议(例如,超文本传输协议安全(HTTPS))和/或使用远程过程调用(RPC)来与区块链网络212通信,或者通过区块链网络212进行通信。
节点214在区块链网络212的参与度可以不同。例如,一些节点214可以参与共识过程(例如,作为将区块添加到区块链216的矿工节点),而其他节点214不参与共识过程。作为另一示例,一些节点214存储区块链216的完整副本,而其他节点214仅存储区块链216的部分副本。在图2的示例中,参与方系统202、204、206各自存储区块链216的完整副本216'、216”、216”'。
区块链(例如,图2中的区块链216)由一连串的区块组成,每个区块存储数据。数据的示例可以包括表示两个或更多参与方之间的交易的交易数据。在本说明书实施例中,交易被使用来作为非限制性示例,可以预期的是,任何适当的数据都可以存储在区块链中(例如,文档,图像,视频,音频)。交易的示例可以包括但不限于交换有价值的东西(例如,资产,产品,服务和货币等)。交易数据被不可更改地存储在区块链中。
在存储在区块中之前,对交易数据进行哈希处理。哈希处理是将(作为字符串数据提供的)交易数据转换为固定长度的哈希值(也被作为字符串数据提供)的过程。通过对交易数据进行哈希处理后,即使交易数据出现轻微更改,也会导致得到完全不同的哈希值。哈希值通常是通过使用哈希函数来对交易数据进行哈希处理而生成的。哈希函数的示例包括但不限于安全散列算法(SHA)-256,其输出256比特的哈希值。
多个交易的交易数据可以在被哈希化之后存储在区块中。例如,对两个交易数据进行哈希处理得到两个哈希值,然后,对所得到的两个哈希值再次进行哈希处理以得到另一哈希值。重复该过程,直到对于要存储在区块中的所有交易,得到单个哈希值。该哈希值被称为Merkle根哈希,并且被存储在区块的头部。任何交易的更改都会导致其哈希值发生变化,最终导致Merkle根哈希值发生变化。
通过共识协议来将区块添加到区块链中。区块链网络中的多个节点参与共识协议,并且经过竞争之后将区块添加到区块链中。这样的节点被称为矿工节点(或记账节点)。以上介绍的POW用作非限制性示例。
矿工节点执行共识过程来将交易(所对应的区块)添加到区块链。虽然多个矿工节点参与共识过程,但只有一个矿工节点可以将区块写入区块链。也就是说,矿工节点在共识过程中竞争以将其区块添加到区块链中。更详细地,矿工节点周期性地从交易池中收集待处理的交易(例如,直到达到在区块中可以包括的交易数量的预定限制,如果有的话)。交易池包括来自区块链网络中的参与方的交易消息。矿工节点创建区块,并将交易添加到区块中。在将交易添加到区块之前,矿工节 点检查待添加的交易中是否存在区块链的区块中具有的交易。如果该交易已被添加到另一个区块中,则该交易将被丢弃。
矿工节点生成区块头,对区块中的所有交易进行哈希处理,并且成对地组合哈希值以生成进一步的哈希值,直到针对区块中的所有交易得到单个哈希值(Merkle根哈希)。然后,将Merkle根哈希添加到区块头中。矿工还确定区块链中的最新区块(即,添加到区块链的最后一个区块)的哈希值。矿工节点还可以在区块头中添加随机数值(noune值)和时间戳。在挖掘过程中,矿工节点尝试找到满足所需参数的哈希值。矿工节点不断更改nonce值,直到找到满足所需参数的哈希值。
区块链网络中的每个矿工都试图找到满足所需参数的哈希值,并且以这种方式彼此竞争。最终,一个矿工节点找到满足所需参数的哈希值,并将该哈希值通告给区块链网络中的所有其他矿工节点。其他矿工节点验证哈希值,如果确定为正确,则验证区块中的每个交易,接受该区块,并将该区块附加到它们的区块链副本中。以这种方式,区块链的全局状态在区块链网络内的所有矿工节点上达成一致。上述过程是POW共识协议。
在图2所提供的示例中,参与方A想要向参与方B发送一定数量的资金。参与方A生成交易消息,并将交易消息发送到区块链网络,该交易消息被增加到交易池中。区块链网络中的每个矿工节点创建区块,并从交易池中获取交易,并将交易添加到区块。按照这种方式,参与方A所发布的交易被添加到矿工节点的区块中。
在一些区块链网络中,实施密码技术来维护交易的隐私性。例如,如果两个节点想要保持交易私密性,使得区块链网络中的其他节点不能获悉交易细节,则节点可以对交易数据进行加密处理。加密方法的示例包括但不限于对称加密和非对称加密。对称加密是指使用单个密钥进行加密(根据明文生成密文)和解密(根据密文生成明文)的加密过程。在对称加密中,多个节点可以使用相同的密钥,因此每个节点都可以对交易数据进行加密/解密。
非对称加密是指使用密钥对来进行加密。每个密钥对包括私钥和公钥,私钥仅对于相应节点是已知的,并且公钥对于区块链网络中的任何或所有其他节点是已知的。节点可以使用另一个节点的公钥来加密数据,并且可以使用其他节点的私钥来解密经过加密的数据。例如,再次参考图1。参与方A可以使用参与方B的公钥来加密数据,并将加密数据发送给参与方B.参与方B可以使用其私钥来解密加密数据(密文)并提取原始数据(明文)。使用节点的公钥加密的消息,只能使用该节点的私钥解密。
非对称加密用于提供数字签名,这使得交易中的参与方能够确认交易中的其他参与方以及交易的有效性。例如,节点可以对消息进行数字签名,而另一个节点可以根据参与方A的数字签名确认消息是由该节点发送的。数字签名还可以用于确保消息在传输过程中不被篡改。例如,再次参考图1。参与方A将向参与方B发送消息。参与方A生成消息的哈希值,然后使用其私钥对哈希值进行加密来生成数字签名。参与方A将该数字签名附加到消息,并将具有数字签名的消息发送给参与方B。参与方B使用参与方A的公钥解密数字签名,从而解密出对应的哈希值。参与方B对所接收 的消息进行哈希处理以得到另一哈希值,然后比较两个哈希值。如果哈希值相同,则参与方B可以确认该消息确实来自参与方A,并且未被篡改。
虽然以上对可以适用本说明书实施例的区块链场景进行了说明,但是本说明书实施例还可以适用于其它块链式场景。例如,本说明书实施例还可以适用于类区块链系统。在类区块链系统中,数据可以同样地采用块链式结构来存储,与区块链系统不同的是,在类区块链系统中,存储于块链式结构中的块链数据不需要经过共识处理。
在以下所描述的实施例中,“底层块链式层”是指多层块链式结构的最下层块链式层,“上层块链式层”是指该多层结构中的除底层块链式层之外的各个块链式层,“块链式层”包括底层块链式层和各个上层块链式层。“底层区块”是指底层块链式层中的区块,“上层区块”是指各个上层块链式层中的区块。“相邻上层块链式层”是指相邻的“上一层上层块。“下层”是指“下一层”,例如“下层区块”是指某块链式层的下一层块链式层中的区块。“基准区块”是指各个块链式层中满足预定条件而触发生成对应上层区块的区块,“上一基准区块”是指在同一块链式层中的上一基准区块,例如“基准区块的上一基准区块”中的“基准区块”和“上一基准区块”是指在同一块链式层中相邻的基准区块。“前一区块”或“后一区块”是指在本说明书中提及的验证路径中的某区块的前一区块或后一区块,该区块与其前一区块或后一区块可能位于同一块链式层,也可能位于不同的块链式层。“块高”是指区块在相应块链式层中所处的位置。例如,如果定义各个块链式层的第一个区块的块高为0,则该块链式层的第三个区块的块高可以为2。类似地,如果定义各个块链式层的第一个区块的块高为1,则该块链式层的第三个区块的块高可以为3。块高可以以任意有序的方式来确定,只要能够基于块高定位各个区块在相应块链式层的位置即可。
图3是根据本说明书的一个实施例的用于生成多层块链式结构的方法的流程图。
如图3所示,在块320,基于交易数据生成多层块链式结构的底层块链式层的底层区块。底层块链式层的底层区块可以采用生成块链式结构的任意方法生成,例如可以采用上述参考图1和图2说明的区块链生成方法生成,或采用比特币、以太坊等区块链生成方法来生成。各个交易数据可以在经过各个区块链节点的共识处理和智能合约执行处理之后被打包成底层区块。在类区块链系统中,被上链的交易数据可以不经过共识处理。
在块340,确定底层块链式层中是否存在触发上层块链式层生成条件的基准区块。各个块链式层中的基准区块是与上层块链式层中的各个区块对应的区块。例如,可以基于底层块链式层中的各个区块与其上一基准区块之间的区块数目是否达到指定数目来确定基准区块,还可以基于底层块链式层中的各个区块的生成时间与其上一基准区块的生成时间之间的时间间隔是否达到指定时间间隔来确定基准区块。在本说明书中,在确定区块与另一区块之间的区块数时将该另一区块包括在内。
在确定出基准区块时,在块360,响应于底层块链式层中存在触发上层块链式层生成条件的基准区块,至少部分地基于该基准区块的区块信息,生成上层块链式层的对应上层区块。多层块链式结构可以具有一个上层块链式层,还可以包括多个上层块链式层。当多层块链式结构具有多个上层 块链式层时,在基于底层块链式层生成底层块链式层之后,还可以以同样的方式,针对各个上层块链式层,逐次地基于该上层块链式层生成相邻上层块链式层。具体地,可以针对各个上层块链式层,确定该上层块链式层是否存在触发上层块链式层生成条件的基准区块。当存在触发上层块链式层生成条件的基准区块时,至少部分地基于该基准区块的区块信息生成该上层块链式层的相邻上层块链式层。以下结合图4来对多层块链式结构的生成过程进行描述。
图4是根据本说明书的一个实施例的多层块链式结构的示意图。在图4中示意性地示出了四个块链式层,但是本说明书实施例对块链式层的数量没有限制。在图4中,B ij表示第i个块链式层的第j个区块,例如B 11表示第一个块链式层(即底层块链式层)的第一个区块,B 22表示第二个块链式层(即第一上层块链式层)的第二个区块。
在图4中,B 11为创世区块,创世区块是指底层块链式层的第一个区块。随着块链式系统处理的交易数据的增加,依次生成底层块链式层的区块B 12至B 111等。各个上层块链式层基于该上层块链式层的下层块链式层生成。例如,第一上层块链式层基于底层块链式层生成,第二上层块链式层基于第一上层块链式层生成。各个上层块链式层的第一个区块可以被称为头区块(如头区块B 21、B 31、B 41)。
在一个示例中,可以将各个块链式层的第一个区块确定为该块链式层的第一个基准区块(例如区块B 11、B 21、B 31),然后基于该基准区块生成该块链式层的上层块链式层的头区块(例如区块B 21、B 31、B 41)。可以针对各个上层块链式层,使该上层块链式层的头区块包括该上层块链式层的下层块链式层的第一个区块的哈希值。各个上层块链式层的头区块还可以基于创世区块来生成,例如各个上层块链式层的头区块可以包括创世区块的哈希值。在另一示例中,在生成各个上层块链式层的头区块时,可以复制创世区块以生成该上层块链式层的头区块。通过使各个头区块基于创世区块生成,能够快速地从创世区块定位至各个上层块链式层。
虽然图4中示出了各个上层块链式层的头区块均与创世区块对应的情形,但是在另一示例中,可以针对各个块链式层,将与该块链式层的第一个区块之间的区块数达到指定数目的区块或生成时间与第一个区块的生成时间之间的时间间隔达到指定时间间隔的区块确定为该块链式层的第一个基准区块。例如,可以对图4所示出的示例进行如下简单变形,即各个上层块链式层可以不包括图4所示出的区块B 21、B 31、B 41,从而将图4示出的B 22、B 32、B 42作为第一个区块。作为示例,可以将底层块链式层的区块B 13确定为底层块链式层的第一个基准区块,然后可以基于B 13来生成第一上层块链式层的第一个上层区块。在该示例中,各个上层块链式层的第一个上层区块可以包括创世区块的哈希值,以快速地从底层块链式层定位至各个上层块链式层,或从各个上层块链式层定位于至底层块链式层。
在确定各个块链式层的第一个基准区块之后,可以以与上一基准区块之间的区块数目达到指定数目或生成时间与上一基准区块的生成时间之间的间隔达到指定时间间隔作为触发条件,来确定各个块链式层的其它基准区块。例如,可以利用如下述参照图5A至图6B描述的过程来确定各个块 链式层的各个基准区块,并对应于所确定的基准区块生成上层区块。各个块链式层的生成可以是实时并行执行的,还可以在底层块链式层的各个区块被生成之后,根据系统的计算资源占用情况,在合适的时机生成的各个上层块链式层。
图5A和图5B示出了与底层块链式层非同步地生成上层块链式层的示例。可以在各个块链式层中的各个区块被生成之后,在合适的时机(如系统资源充裕时),遍历该块链式层中未执行基准区块确定过程的区块,即一一查询各个区块,以确定当前被查询区块是否是触发上层块链式层生成条件的基准区块。在确定出基准区块后,可以生成上邻上层块链式层的对应上层区块。例如,可以在生成各个底层区块之后,在合适的时间段遍历所生成各个底层区块,以确定出触发生成第一上层块链式层中的上层区块的基准区块。
图5A是根据本说明书的一个实施例的用于生成多层块链式结构的方法中的基准区块确定过程的流程图。
如图5A所示,在块5A02,针对各个块链式层,确定该块链式层的当前被查询区块与上一基准区块之间的区块数。然后在块5A04,确定当前被查询区块与上一基准区块之间的区块数是否达到指定数目。在本说明书实施例中,区块与另一区块之间的区块包括该另一区块,相应地,在提及区块与另一区块之间的区块数时,应将该另一区块计算在内。例如,B 11和B 13之间的区块包括B 12和B 13,相应地,B 11与B 13之间的区块数为2。
如果当前被查询区块与上一基准区块之间的区块数达到指定数目,则在块5A06,将当前被查询区块确定为基准区块。可以设定各个块链式层的基准区块之间的区块数,例如对于图4中的示例,可个基准区块与上一基准区块之间的区块数为2。如果当前被查询区块与上一基准区块之间的区块数达到了所设定的指定数目,则可以将当前被查询区块确定为基准区块。
如果当前被查询区块与上一基准区块之间的区块数未达到指定数目,则在块5A08,将该块链式层的下一区块作为当前被查询区块,并再次执行上述过程。
图5B是根据本说明书的一个实施例的用于生成多层块链式结构的方法中的基准区块确定过程的另一示例流程图。
如图5B所示,在块5B02,针对各个块链式层,确定该块链式层的当前被查询区块与上一基准区块的生成时间之间的时间时隔。各个区块的生成时间例如可以基于该区块的时间戳来确定。然后在块5B04,判断所确定出的时间间隔是否达到指定时间间隔。
如果所确定出的时间间隔达到指定时间间隔,则在块5B06,将当前被查询区块确定为基准区块。如果所确定出的时间间隔未达到指定时间间隔,则在块5B08,将该块链式层的下一区块作为当前被查询区块,并再次执行上述过程。
图6A和6B示出了与底层块链式层同步地生成上层块链式层的示例。可以对各个块链式层中的区块进行监听,在监听到各个块链式层有新区块加入时,确定该新区块是否是触发上层块链式层 生成条件的基准区块。对于全量节点,新加入的区块可以是新生成的区块,对于轻量节点,新加入的区块还可以是从全量节点获取的区块。轻量节点处的各个区块可以仅包括区块头。轻量节点可以在本地生成上层块链式层中和上层区块,还可以从全量节点处获取各个上层块链式层。
图6A是根据本说明书的一个实施例的用于生成多层块链式结构的方法中的基准区块确定过程的另一示例流程图。
如图6A所示,在块6A02和块6A04,监听各个块链式层是否有新区块加入。
当某个块链式层有新区块加入时,在块6A08,确定新区块与上一基准区块之间的区块数。然后,在块6A10,判断所确定的区块数是否达到了指定数目。
如果所确定的区块数达到指定数目,则在块6A12,将该新区块为相应块链式层的基准区块。如果所确定的区块数未达到指定数目,则继续对该块链式层进行监听。
图6B是根据本说明书的一个实施例的用于生成多层块链式结构的方法中的基准区块确定过程的另一示例流程图。
图6B所示,在块6B02和块6B04,监听各个块链式层是否有新区块生成。
当某个块链式层有新区块生成时,在块6B08,确定新区块的生成时间与上一基准区块的生成时间之间的时间间隔。然后,在块6B10,判断所确定的时间间隔是否达到了指定时间间隔。
如果所确定的时间间隔达到指定时间间隔,则在块6B12,将该新区块为相应块链式层的基准区块。如果所确定的时间间隔未达到指定时间间隔,则继续对该块链式层进行监听。
以图4为例,在该多层块链式结构中,底层块链式层的基准区块为B 11、B 13、B 15等,第一上层块链式层的基准区块为B 21、B 23、B 25等,第二上层块链式层的基准区块为B 31、B 33等。
需要说明的是,在本说明书的实施例中,在基于与上一基准区块之间的区块数目是否达到指定数目来确定基准区块时,同一块链式层的相邻两个基准区块之前的区块数目可以相同也可以不同,各个块链式层所对应的指定数目可以相同也可以不同。此外,当基于生成时间之间的时间间隔来确定基准区块时,同一块链式层的相邻两个基准区块之前的生成时间间隔可以相同或不相同,各个块链式层所对应的指定时间间隔可以相同也可以不同。在一个示例中,可以使各个块链式层的各个基准区块对应的指定数目或指定时间间隔均相同,或者可以针对各个块链式层,使该块链式层的各个基准区块对应的指定数目或指定时间间隔均相同。在该块链式层的各个基准区块对应的指定数目或指定时间间隔均相同时,还可以基于预定规则来确定各个块链式层所对应的指定数目或指定时间间隔。例如,可以使得各个块链式层的相邻基准区块间的区块数以等差数列方式递增。由此,能够基于各个基准区块对应的指定数目或指定时间间隔,实现各个块链式层之间的快速定位。
在确定出基准区块之后,可以基于从该块链式层的第一个区块到该基准区块的所有区块中的至少部分区块的区块信息,生成该块链式层的上层块链式层的对应区块。对于底层块链式层,第一个区块是创世区块,对于各个上层块链式层,第一个区块是相应上层块链式层的头区块。区块信息 可以是各个区块的哈希值或区块内容,还可以是区块内容中的部分内容(例如该区块的哈希值和时间戳或该区块的父区块的哈希值和该区块的哈希值)。由此,能够使各个块链式层与对应的下层块链式层链接起来,并能够基于相应区块信息来进行链路验证。
在一个示例中,所生成的上层区块可以包括该基准区块的哈希值。参考图4,第一上层块链式层的区块B 22可以包括基准区块B 13的哈希值。在另一示例中,针对各个块链式层,可以对该块链式层的第一个区块至基准区块的所有区块的区块内容进行哈希运算得出哈希值,并使对应于该基准区块上层区块包括该哈希值。参考图4,在生成区块B 23时,可以对从B 11至B 15的所有区块的区块内容进行哈希运算以得到哈希值,然后使区块B 23包括该哈希值。在另一示例中,针对各个块链式层,可以对该块链式层的第一个区块至基准区块的所有区块的哈希值进行哈希运算得出哈希值,并使对应于该基准区块对应的上层区块包括该哈希值。如图所示,可以对从B 11至B 15的所有区块的哈希值进行哈希运算以得到哈希值,然后使区块B 23包括该哈希值。在另一示例中,针对各个块链式层,还可以将该块链式层的第一个区块和基准区块的区块内容或哈希值进行哈希运算得到哈希值,并使对应于该基准区块的上层块链式层的区块包括该哈希值。如图4所示,对于基准区块B 15,可以对B 11和B 15的区块内容或哈希值进行哈希运算以得到哈希值,然后使对应于B 15所生成的上层区块B 23包括该哈希值。此外,对应于相应基准区块所生成的上层区块还可以包括利用以上示例所确定出的多个哈希值。
此外,对应于各个块链式层的各个基准区块所生成的上层块链式层的区块还可以具有已知的块链式结构的区块属性。例如,各个上层块链式层的上层区块可包括该上层区块的前一上层区块(父区块)的哈希值。
在另一示例中,还可以存储基准区块与所对应的上层区块的区块索引信息。区块索引信息有助于在各个块链式层之间进行定位。区块索引信息例如可以为基准区块或基准区块所对应的上层区块的块高。区块索引信息可以被包括在基准区块中,基准区块可以包括不参与该基准区块的哈希值运算的字段,可以在生成对应的上层区块之后,将该上层区块的块高写入该字段。区块索引信息可以被包括在基准区块所对应的上层区块中。例如,可以使上层区块的区块头包括基准区块块高字段,在生成对应的上层区块时,将该对应的基准区块的块高写入基准区块块高字段。区块索引信息还可以被包括在基准区块所对应的上层区块的下一区块中。可以在生成该上层区块的下一区块时,将该上层区块的基准区块的块高写入该下一区块的区块头中。在另一示例中,还可以设置索引数据库,在对应于基准区块生成上层区块时,可以将该上层区块与基准区块的区块索引信息存储在索引数据库中。
以下将参考图7至图11来说明本说明书实施例生成的多层块链式结构的应用。如下实施例可以用于区块链系统中的轻量节点。
图7是根据本说明书的一个实施例的用于更新多层块链式结构中的信任点的方法的流程图。信任点指示底层块链式层中的块高最大的已验证底层区块。信任点表示在节点处存储的底层区块中, 从创世区块至信任点所指示的底层区块均已经通过了验证,即这些底层区块是被信任的区块。信任点的初始值可以是创世区块,例如,对于从未执行过区块验证的轻量节点,信任点指向创世区块。信任点可以存储在轻量节点处,可以在执行完一个批次的区块验证之后,轻量节点可以将信任点更新为指向当前区块最高的已验证底层区块,例如可以在信任点字段存储当前块高最大的已验证底层区块的块高或哈希值。作为信任点的一种应用,在轻量节点对待验证交易进行SPV验证时,如果待验证交易所在的底层区块位于信任点之前(即该底层区块是已验证过的可信任底层区块),则可以对该待验证交易进行存在性证明,并在存在性证明验证通过后确定该待验证交易已被正确执行。
如图7所示,在块720,基于多层块链式结构,确定当前信任点所指示的已验证底层区块与目标底层区块之间的验证路径。轻量节点可以在需要更新信任点时,从全量节点获取当前信任点指示的已验证区块与目标底层区块之间的各个块链式层的区块,并将所获取的区块添加到本地的各个块链式层中。然后,轻量节点可以基于本地存储的多层块链式结构来确定验证路径。参考图4,当前信任点可以指向底层块链式层的区块B 14。目标底层区块例如可以是图4中的B 112
在一个示例中,可以在对待验证交易进行SPV验证时更新信任点,目标底层区块可以基于待验证交易所在的待验证底层区块来确定。图8是根据本说明书的一个实施例的对待验证交易进行SPV验证的方法的流程图。
如图8,在块802,确定待验证交易所在的待验证底层区块。当轻量节点想要获知某个交易是否被正确执行时,可以从全量节点处获取该交易所在的底层区块。全量节点可以将该交易所在的底层区块的块高发送给轻量节点。然后,轻量节点可以对该交易进行SPV验证。SPV验证可以包括正确性验证和存在性验证(或称为存在性证明)。正确性验证可以通过验证从创世区块至待验证底层区块之间的链路完整性来执行,用于证明待验证交易是正确的。存在性验证用于证明待验证交易确实存在于待验证区块中,可以基于任意存在性证明方法来执行。例如,可以基于MPT树获取待验证交易在MPT树中的查询路径,并基于所获取的查询路中各个MPT树的数据节点来验证交易树根哈希是否与块头中的交易树根哈希一致,当二者一致时,可以确定待验证交易确实存在于待验证底层区块中。
在确定待验证底层区块之后,在块804,确定待验证底层区块是否位于信任点之前。即,确定待验证底层区块是否是可信任的底层区块。可以通过比较待验证区块的块高与信任点所指向的已验证底层区块块高来确定待验证交易是否位于信任点之前。
当待验证底层区块位于信任点之前时,表明从创世区块至待验证交易所在的待验证底层区块之间的链路是正确的。因而可以在块808,对待验证交易进行存在性证明,并在块810,确定存在性证明是否通过。当待验证底层区块不是位于信任点之前时,可以在块806,使用本说明书实施例所描述的信任点更新方法,将信任点更新至块高不小于待验证底层区块的目标底层区块。此时,块高不小于待验证交易所在的底层区块的任意底层区块均可以作为目标底层区块。在更新信任点之后,可以在块808,对待验证交易进行存在性证明。
如果存在性证明通过,则可以在块812,确定待验证交易已被正确执行。如果存在性证明不通过,则可以在块814,确定待验证交易未被正确执行。
验证路径是指从当前信任点验证至目标底层区块的路径。验证路径可以经由任意块链式层。例如,如图4所示,从当前信任点TP至目标底层区块B 112之间的验证路径可以是B 15→B 23→B 32→B 33→B 25→B 26→B 111→B 112
验证路径可以只经由底层块链式层,还可以经由至少一个上层块链式层来确定。由于各个块链式层的相邻两个基准区块之间间隔有至少一个区块,因而该块链式层的上层区块相当于“跳过”了所间隔的区块。由此,在经由至少一个上层块链式层来确定验证路径时,能够减少验证路径中的区块数,从而提高验证效率。可以从当前信任点所指向的已验证底层区块与目标底层区块之间的所有路径中,选择最短路径(即经过区块最少的路径)以作为验证路径。
在经由上层块链式层确定验证路径时,在从各个块链式层上升到上层块链式层或从上层块链式层下降至下层块链式层时,存在路径损耗。即,由于在块链式层之间的上升或下降,可能出现路径所经由的区块数增加的情况。因此,在当前信任点所指示的已验证底层区块与目标底层区块之间的区块数较少时,如果经由上层块链式层可能会导致验证路径比仅经由底层块链式层确定的验证路径要长。因而,在一个示例中,可以在当前信任点所指示的已验证底层区块与目标底层区块之前至少存在两个底层基准区块时,经由至少一个上层块链式层来确定验证路径。在另一示例中,所确定出的目标底层区块与当前信任点所指示的已验证底层区块之间的底层区块数可以大于第一预定数量。由此,目标底层区块与当前信任点所指向的已验证底层区块之间的底层区块数足够大,因而可以在每次更新信任点时经由至少一个上层块链式层来确定验证路径。当目标底层区块与当前信任点所指示的已验证底层区块之间的底层区块数大于第二预定数量(第二预定数量不小于第一预定数量)时,可以经由多个上层块链式层来确定验证路径,从而能够尽量地减少验证路径中所包括的区块数,以提高验证效率。
验证路径可以基于第一区块数和第二区块数来确定,第一区块数是各个块链式层的相邻两个基准区块之间的区块数,第二区块数是目标底层区块与已验证底层区块之间的底层区块数。在一个示例中,在各个块链式层中相邻两个基准区块之间可以存在相同数量的区块,即相邻两个基准区块之间的第一区块数相等。在该示例中,假设第一区块数为N,则第L层块链式层中的相邻两个区块之间所存在的底层区块数为N L-1个。例如,参考图4,第二个块链式层(即第一上层块链式层)中的相邻两个区块之间有2 2-1个底层区块。可以基于第一区块数和第二区块数来确定验证路径所经由的块链式层的上升点,对于验证路径所经过的各个区块,如果该区块的后一区块是相临上层块链式层的区块,则该区块被称为上升点。在验证路径中第L个块链式层的上升点所对应的区块在第L层块链式层中的序号为(%表示取余运算):
X+[N-(X-1)%N]%N,
其中,B LX为验证路径中的第L个块链式层的第一个区块。例如,在图4所示的验证路径中, 对于第二个块链式层(即第一上层块链式层),其上升点为3+[2-(3-1)%2]%2,运算结果为3,即X的值是3,因此第二个块链式层中的第三个区块B 23为上升点。
验证路径所经过的各个块链式层的下降点也可以基于第一区块数和第二区块数来确定。对于验证路径所经过的各个区块,如果该区块的后一区块是下层块链式层的区块,则该区块被称为下降点。假设当前信任点所指示的已验证区块为B 1j(底层块链式层的第j个区块),目标底层区块为B 1k(底层块链式层的第k个区块)。则第L层块链式层中的下降点所对应的区块的序号为:
(k-k%N)/N L-1
如果某区块同时符合上升点和下降点的条件,则将该区块确定为下降点(如B 33)。
在确定出各个块链式层中的上升点和下降点之后,该块链式层中的上升点和下降点之间的区块均是验证路径中的区块。在图4所示出的示例中,确定出的上升点分别是B 15、B 23,下降点分别是B 33和B 26
在各个块链式层中相邻两个区块之间的第一区块数相等时,为了使得所确定出的验证路径是当前信任点所指向的已验证底层区块和目标底层区块之间的最短路径,可以使得所经过的块链式层的最大层数不超过第一区块数。例如,以图4为例,通过上述实施例所确定出的验证路径B 15→B 23→B 32→B 33→B 25→B 26→B 111→B 112包括8个区块。如果使验证路径所经过的块链式层的最大层数不超过相邻两个基准区块的第一区块数(即2),则验证路径所经过的最大层数为第二个块链式层(即第一上层块链式层),那么所确定的验证路径将会是B 15→B 23→B 24→B 25→B 26→B 111→B 112,该验证路径包括7个区块。即,验证路径相对于经过的块链式层数超过第一间隔区块数时的情形被缩短了。
对于各个块链式层中的相邻两个基准区块之间的第一区块数不相等的情况,第一区块数可以基于区块索引信息来确定。由于区块索引信息中包括基准区块与所对应的上层区块之间的索引关系,可以基于区块索引信息来确定已验证底层区块与目标底层区块之间的各层块链式层中的基准区块,并确定出各层块链式层中相邻两个基准区块之间的第一区块数。在确得到第一区块数之后,出在经由上层块链式层确定验证路径时,可以基于相邻两个基准区块之间的第一区块数和已验证底层区块与目标底层区块之间的第二区块数,计算得出各层块链式层应当被包括在验证路径中的区块。
如果相邻两个基准区块之间的区块数不完全相等,还可以基于区块索引信息确定验证路径,区块索引信息指示各个基准区块与所对应的上一层区块之间的索引。可以基于区块索引来确定各个块链式层中的基准区块,然后可以在上升到各个上层块链式层之后,可以通过试探的方式来确定该块链式层的下一区块是否已达到或超过目标底层区块。如果达到或超过了底层区块,则舍弃该块链式层,并下降到下层块链式层继续查找。
由于区块索引信息中存储有各个基准区块与对应上层区块之间的索引关系,因而可以基于区块索引信息来确定在上层块链式层中的各个上层区块实际上是否已超过目标底层区块。例如,区块索引信息可以被包括在各个基准区块中,各个基准区块中可以包括上层区块索引字段,例如可以把该基准区块所对应的上层区块的块高或哈希值写入该基准区块的上层区块索引字段。在确定验证路 径时,可以从当前信任点所指向的已验证底层区块起查询各个底层区块,当被查询区块的上层区块索引字段为空时表明该被查询区块不是相应块链式层的基准区块,当上层区块索引字段不为空时,表明该被查询区块是基准区块。此时,可以基于上层区块索引信息确定该被查询区块所对应的上层区块,然后上升到相邻上层块链式层继续进行查询。在上层块链式层进行查询时,如果确定出某个上层区块是相应上层块链式层中的基准区块,由于上层区块中包括相应下层区块的索引,可以基于相应下层区块的索引确定该上层区块所能够定位到的底层区块是否已超过了目标底层区块。如果没有超过目标底层区块,则可以继续上升到上层块链式层,若超过了目标底层区块则回退到该上层块链式层的前一上层区块,并下降到下层块链式层。在下降到该上层块链式层的下层块链式层之后,如果该下层块链式层仍然是上层块链式层,则可以继续确定所下降到的下层区块的下一区块是否超过目标底层区块。如果下一区块没有超过目标底层区块,则该下层区块的下一区块可以被确定为验证路径中的区块。如果该下层区块的下一区块已超过目标底层区块,则继续下降,直到下降到底层区块链为止。执行上述过程直到查询至目标底层区块即可确定出验证路径。
在确定验证路径之后,在块740,针对验证路径中的各个区块,验证该区块与前一区块之间的链路是否正确。链路验证过程可以基于各个区块之间的链接关系来确定。对于验证路径中位于同一块链式层的区块,每个区块中存储有父哈希,因而可以基于前一区块的区块信息来验证各个区块与前一区块之间的链路是否正确。例如,以图4中实线箭头所指示的验证路径为例,B 14和B 15、B 32和B 33分别位于底层块链式层和第二上层块链式层,B 14是B 15的父区块,B 32是B 33的父区块。因而可以基于B 15中的父哈希和B 14的区块信息来验证B 14与B 15之间的链路是否正确。对于位于不同块链式层的相邻区块,由于上层区块是基于下层的对应基准区块生成的,因而可以基于对应基准区块的区块信息来验证该两个相邻区块之间的链路是否正确。以图4中示出的验证路径为例,B 15与B 23、B 32分别位于不同的块链式层,B 15是B 23的基准区块、B 23是B 32的基准区块。由于B 23是至少基于B 15的区块信息生成的、B 32是至少基于B 23的区块信息而生成的,因而可以基于B 15和B 23的区块信息来验证B 15和B 23之前的链路,并基于B 23和B 32的区块信息来验证B 23和B 32之前的链路。具体的链路验证过程将在下文参照图9来进行描述。
需要说明的是,验证路径中各个区块之间的链路验证过程可以是在确定验证路径之后执行的,也可以是在确定验证路径的过程中执行的。例如,对于图4所示出的验证路径,可以在确定B 14的下一区块(即B 15)时,验证B 14与B 15之间的链路,然后确定B 15的下一区块。在确定出B 15的下一区块(即B 23)之后,验证B 15与B 23之间的链路。在验证路径的确定过程以及链路验证过程中,当出现任意两个区块之前的链路不正确时,即可以确定验证路径中的链路不正确。
然后,在块760,确定验证路径中的各个区块之间的链路是否均正确。当验证路径中的各个区块之间的链路均正确时,在块780,将信任点更新为指示目标底层区块。
验证路径中的各个区块中可以存储有至少基于前一区块的区块信息生成的第一哈希值。如果该区块的前一区块与该区块位于相同块链式层,则第一哈希值可以是该区块的父哈希。如果该区块的前一区块与该区块位于不同块链式层,则第一哈希值可以是至少部分地基于该前一区块的区块信 息来进行哈希运算得到的。此时,可以利用如图9所示的示例来进行链路验证。图9是根据本说明书的一个实施例的用于更新区块链中的信任点的方法中的链路验证过程的流程图。
如图9所示,在块902,针对验证链路中的各个区块,至少基于上一区块的区块信息进行哈希运算,以得到第二哈希值。然后,在块904,确定所得到的第二哈希值与该区块中的第一哈希值是否一致。当二者一致时,在块906,确定该区块与前一区块之间的链路是正确的。当二者不一致时,在块908,确定该区块与前一区块之间的链路是不正确的。
当该区块的前一区块与该区块位于相同块链式层时,可以对前一区块的区块头进行哈希运算以得到第二哈希值。然后,可以比较该第二哈希值与该区块中的父哈希的一致性。例如,以图4中实线箭头所指示的验证路径为例,由于B 14是B 15的父区块,因而可以对B 14的区块信息进行哈希运算以得到哈希值,并比较所得到的哈希值与B 15中存储的父哈希的一致性。当二者一致时,可以确定B 14和B 15之间的链路是正确的。
当该区块的前一区块与该区块位于不同块链式层时,前一区块是该区块的基准区块,因而可以至少部分地基于前一区块的区块信息来进行哈希运算,以得到第二哈希值。例如,上层区块可以包括对应基准区块的哈希值。在该示例中,如果验证路径中的某个区块的前一区块位于下层块链式层,则可以对前一区块的区块信息进行哈希运算以得到第二哈希值。以图4中示出的验证路径中的B 15与B 23为例,可以对B 15的区块头进行哈希运算以得到第二哈希值。然后可以比较所得到的第二哈希值与B 23中存储的B 15的哈希值是否一致,如果二者一致则可以确定B 15和B 23之间的链路是正确的。再例如,在对应于基准区块来生成上层区块时,可以对从基准区块所在的块链式层中,从第一个区块至该基准区块的所有区块的区块信息进行哈希运算,并将所得到的哈希值作为第一哈希值存储在所生成的上层区块中。在该示例中,如果验证路径中的某个区块的前一区块位于下层块链式层,可以对前一区块所在的块链式层中的第一个区块至该前一区块的所有区块信息进行哈希运算,以得到第二哈希值。以图4中示出的验证路径中的B 15与B 23为例,可以对B 11、B 12、B 13、B 14和B 15的区块信息进行哈希运算以得到第二哈希值。然后可以比较所得到的哈希值与B 23中存储的第一哈希值,如果二者一致则可以确定B 15与B 23之间的链路是正确的。
在验证路径中的各个区块之间的链路被验证为正确之后,还可以对目标底层区块的正确性进行验证。目标底层区块的正确性可以通过验证其是否经过了全网共识来执行。图10是根据本说明书的另一实施例的用于更新区块链中的信任点的方法的流程图。
如图10所示,在块1002,基于多层块链式结构,确定当前信任点所指示的已验证底层区块与目标底层区块之间的验证路径。在确定验证路径之后,在块1004,针对验证路径中的各个区块,验证该区块与该区块的前一区块之间的链路是否正确。然后在块1006,判断是否验证路径中各个区块之间的链路均被验证为正确。
如果各个区块与上一区块之间的链路均被验证为正确,则在块1008,确定目标底层区块是否正确。可以参照图11所示的示例来验证目标底层区块是否正确。
图11是根据本说明书的一个实施例的用于更新多层块链式结构中的信任点的方法中的目标底层区块验证过程的流程图。
如图11所示,在块1102,从区块链系统中的多个全量节点处获取目标底层区块的多个目标底层区块信息。
然后,在块1104,当多个目标底层区块信息中存在不低于法定数量的一致的目标底层区块信息时,确定目标底层区块是正确的。当存在不低于法定数量的一致的目标底层区块信息时,可以确定目标底层区块已经过全网共识,因而可以确定其是正确的。
在目标底层区块被确定正确时,在块1010,将信任点更新为指示目标底层区块。如果验证路径各个区块与上一区块之间的链路不完全正确或目标底层区块被确定为不正确,则表明目标底层区块不能信任的区块。在这种情况下,可以重新确定目标底层区块,并执行信任点更新过程。
在多层块链式结构应用于中心化的类区块链系统时,各个底层块链式层中的各个区块在被生成以后,可以将该区块发送给所信任的第三方服务器,第三方服务器可以利用其私钥对该区块进行签名认证。在验证目标底层区块是否正确时,可以从第三方服务器获取针对该目标底层区块的签名,然后用第三方服务器的公钥对所获取的目标底层区块的签名进行验证,验证通过时可以确定目标底层区块是正确的。
通过该实施例,能够进一步保证更新后的信任点的可信程度。图12是根据本说明书的一个实施例的多层块链式结构生成装置的结构框图。如图12所示,多层块链式结构生成装置1200包括底层块链式层生成单元1210和上层块链式层生成单元1220。
底层块链式层生成单元1210基于交易数据生成多层结构中的底层块链式层的区块。上层块链式层生成单元1220根据上层块链式层生成条件,基于底层块链式层生成上层块链式层。上层块链式层生成单元1220包括基准区块确定模块1221和上层块链式层生成模块1222。基准区块确定模块1221确定底层块链式层中是否存在触发上层块链式层生成条件的基准区块。上层块链式层生成条件可以包括该基准区块与上一基准区块之间的区块数目达到指定数目,还可以包括该基准区块的生成时间与上一基准区块的生成时间之间的时间间隔达到指定时间间隔。
在一个示例中,基准区块确定模块1221可以遍历多层块链式结构中的各个块链式层中的区块,以确定满足上层块链式层生成条件的基准区块。在另一个示例中,基准区块确定模块1221可以针对区块链中的各个块链式层,确定新生成的区块是否是满足上层块链式层生成条件的基准区块。
上层块链式层生成模块1222响应于底层块链式层中存在触发上层块链式层区块生成条件的基准区块,至少部分地基于该基准区块的区块信息,生成上层块链式层的对应上层区块。
多层块链式结构可以包括多个上层块链式层。在该示例中,上层块链式层生成单元1220可以针对各个上层块链式层,根据相同或者不同的上层块链式层生成条件,基于该上层块链式层生成该上层块链式层的相邻上层块链式层。具体地,基准区块确定模块1221可以针对各个上层块链式层, 确定该上层块链式层中是否存在触发上层块链式层生成条件的基准区块。当存在触发上层块链式层生成条件的基准区块时,上层块链式层生成模块1222可以至少部分地基于该基准区块的区块信息,生成该上层块链式层的相邻上层块链式层的对应上层区块。
在一个示例中,上层块链式层生成模块1222还可以基于从各个块链式层的第一个区块到该基准区块的所有区块中的至少部分区块的区块信息,生成该块链式层的相邻上层块链式层的对应区块。
区块链生成装置还可以包括区块索引信息存储单元(附图中未示出)。区块索引信息存储单元存储基准区块与对应上层区块的区块索引信息。在一个示例中,区块索引信息存储单元可以将区块索引信息存储在基准区块或基准区块所对应的上层区块中,还可以将区块索引信息存储在该上层区块的下一区块中。在另一示例中,区块索引信息存储单元还可以将区块索引信息存储在索引数据库中。
图13是根据本说明书的一个实施例的用于更新多层块链式结构中的信任点的装置的结构框图。如图13所示,信任点更新装置1300包括验证路径确定单元1310、链路验证单元1320、目标底层区块验证单元1330和信任点更新单元1340。
验证路径确定单元1310基于多层块链式结构,确定当前信任点所指示的已验证底层区块与目标底层区块之间的验证路径。在一个示例中,验证路径确定单元1310可以在目标底层区块和已验证底层区块之间存在至少两个底层块链式层的基准区块时,经由至少一个上层块链式层确定验证路径。
在一个示例中,各个块链式层中的相邻两个基准区块之间的第一区块数可以是相等的,验证路径所经过的上层块链式层的数量可以不超过第一区块数。
在一个示例中,验证路径确定单元1310可以基于第一区块数和第二区块数来确定验证路径,第一区块数是各个块链式层的相邻两个基准区块之间的区块数,第二区块数是目标底层区块与已验证底层区块之间的区块数。各个块链式层的相邻两个基准区块之间的第一间隔区块数可以是基于区块索引信息确定的。
在另一示例中,验证路径确定单元1310还可以基于区块索引信息确定验证路径。
在确定验证路径之后,链路验证单元1320针对验证路径中的各个区块,验证该区块与该区块的前一区块之间的链路是否正确。目标底层区块验证单元1330验证目标底层区块是否正确。信任点更新单元1340当验证路径中的各个区块之间的链路均正确并且目标区块是正确的时,将目标底层区块更新为信任点。
在另一示例中,信任点更新装置可以不包括目标底层区块验证单元1330。在该示例中,信任点更新单元1340可以当验证路径中的各个区块之间的链路均正确时,将目标底层区块更新为信任点。
图14是图13所示的用于更新多层块链式结构的信任点的装置中的链路验证单元的结构框图。如图14所示,链路验证单元1320包括哈希运算模块1321和链路验证模块1322。在该示例中,验证路径中的各个区块包括前一区块的第一哈希值。
哈希运算模块1321至少部分地基于本地获取的前一区块的区块信息进行哈希运算,以得到第二哈希值。链路验证模块1322基于第二哈希值与第一哈希值之间的一致性,验证该区块与前一区块之间的链路是否正确。
图15是图13所示的用于更新多层块链式结构中的信任点的装置中的目标底层区块验证单元的结构框图。如图15所示,目标底层区块验证单元1330包括目标底层区块信息获取模块1331和目标底层区块验证模块1332。
目标底层区块信息获取模块1331从区块链系统中的多个全量节点处获取目标底层区块的多个目标底层区块信息。目标底层区块验证模块1332当多个目标底层区块信息中存在不低于法定数量的一致的目标底层区块信息时,确定目标底层区块是否正确。
以上参照图1到6和图12,对根据本说明书实施例的用于生成多层块链式结构的方法及装置的实施例进行了描述,并参照图7到11、13至15对信任点更新方法及装置进行了描述。在以上对方法实施例的描述中所提及的细节,同样适用于本说明书实施例的装置的实施例。
本说明书实施例的多层块链式结构生成装置和信任点更新装置可以采用硬件实现,也可以采用软件或者硬件和软件的组合来实现。本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见。
本说明书实施例的多层块链式结构生成装置和信任点更新装置可以采用硬件实现,也可以采用软件或者硬件和软件的组合来实现。以软件实现为例,作为逻辑意义上的装置,是通过其所在设备的处理器将存储器中对应的计算机程序指令读取到内存中运行形成的。在本说明书实施例中,多层块链式结构生成装置和信任点更新装置例如可以利用计算设备实现。
图16是根据本说明书的一个实施例的用于实现区块链生成方法或信任点更新方法的计算设备的结构框图。如图16所示,计算设备1600包括处理器1610、存储器1620、内存1630、通信接口1640和内部总线1660,并且处理器1610、存储器(例如,非易失性存储器)1620、内存1630、通信接口1640经由总线1660连接在一起。根据一个实施例,计算设备1600可以包括至少一个处理器1610,该至少一个处理器1610执行在计算机可读存储介质(即,存储器1620)中存储或编码的至少一个计算机可读指令(即,上述以软件形式实现的元素)。
在一个实施例中,在存储器1620中存储计算机可执行指令,其当执行时使得至少一个处理器1610:基于交易数据生成多层块链式结构中的底层块链式层的区块;以及根据上层块链式层生成条件,基于底层块链式层生成上层块链式层,其中,根据上层块链式层生成条件,基于底层块链式层生成上层块链式层包括:确定底层块链式层中是否存在触发上层块链式层生成条件的基准区块;响应于底层块链式层中存在触发上层块链式层生成条件的基准区块,至少部分地基于该基准区块的区块信息,生成上层块链式层的对应上层区块。
在另一实施例中,在存储器1620中存储计算机可执行指令,其当执行时使得至少一个处理器 1610:基于多层块链式结构,确定当前信任点所指示的已验证底层区块与目标底层区块之间的验证路径;针对所述验证路径中的各个区块,验证该区块与该区块的前一区块之间的链路是否正确;以及当所述验证路径中的各个区块之间的链路均正确时,将所述目标底层区块更新为信任点。
应该理解,在存储器1620中存储的计算机可执行指令当执行时使得至少一个处理器1610进行本说明书实施例的各个实施例中以上结合图1到6和图12描述的各种操作和功能,或参照图7到11、13至15所描述的各种操作和功能。
根据一个实施例,提供了一种例如非暂时性机器可读介质的程序产品。非暂时性机器可读介质可以具有指令(即,上述以软件形式实现的元素),该指令当被机器执行时,使得机器执行本说明书实施例的各个实施例中以上结合图1到6和图12描述的各种操作和功能,或参照图7到11、13至15所描述的各种操作和功能。
具体地,可以提供配有可读存储介质的系统或者装置,在该可读存储介质上存储着实现上述实施例中任一实施例的功能的软件程序代码,且使该系统或者装置的计算机或处理器读出并执行存储在该可读存储介质中的指令。
在这种情况下,从可读介质读取的程序代码本身可实现上述实施例中任何一项实施例的功能,因此机器可读代码和存储机器可读代码的可读存储介质构成了本发明的一部分。
可读存储介质的实施例包括软盘、硬盘、磁光盘、光盘(如CD-ROM、CD-R、CD-RW、DVD-ROM、DVD-RAM、DVD-RW、DVD-RW)、磁带、非易失性存储卡和ROM。可选择地,可以由通信网络从服务器计算机上或云上下载程序代码。
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。
上述各流程和各系统结构图中不是所有的步骤和单元都是必须的,可以根据实际的需要忽略某些步骤或单元。各步骤的执行顺序不是固定的,可以根据需要进行确定。上述各实施例中描述的装置结构可以是物理结构,也可以是逻辑结构,即,有些单元可能由同一物理实体实现,或者,有些单元可能分由多个物理实体实现,或者,可以由多个独立设备中的某些部件共同实现。
在整个本说明书中使用的术语“示例性”意味着“用作示例、实例或例示”,并不意味着比其它实施例“优选”或“具有优势”。出于提供对所描述技术的理解的目的,具体实施方式包括具体细节。然而,可以在没有这些具体细节的情况下实施这些技术。在一些实例中,为了避免对所描述的实施例的概念造成难以理解,公知的结构和装置以框图形式示出。
以上结合附图详细描述了本说明书实施例的实施例的可选实施方式,但是,本说明书实施例的实施例并不限于上述实施方式中的具体细节,在本说明书实施例的实施例的技术构思范围内,可 以对本说明书实施例的实施例的技术方案进行多种简单变型,这些简单变型均属于本说明书实施例的实施例的保护范围。
本说明书实施例内容的上述描述被提供来使得本领域任何普通技术人员能够实现或者使用本说明书实施例内容。对于本领域普通技术人员来说,对本说明书实施例内容进行的各种修改是显而易见的,并且,也可以在不脱离本说明书实施例内容的保护范围的情况下,将本文所定义的一般性原理应用于其它变型。因此,本说明书实施例内容并不限于本文所描述的示例和设计,而是与符合本文公开的原理和新颖性特征的最广范围相一致。

Claims (19)

  1. 一种用于生成多层块链式结构的方法,所述多层块链式结构包括底层块链式层和上层块链式层,所述方法包括:
    基于交易数据生成多层块链式结构中的底层块链式层的区块;以及
    根据上层块链式层生成条件,基于底层块链式层生成上层块链式层,
    其中,根据上层块链式层生成条件,基于底层块链式层生成上层块链式层包括:
    确定底层块链式层中是否存在触发上层块链式层生成条件的基准区块;
    响应于底层块链式层中存在触发上层块链式层生成条件的基准区块,至少部分地基于该基准区块的区块信息,生成上层块链式层的对应上层区块。
  2. 如权利要求1所述的方法,其中,多层块链式结构包括多个上层块链式层,并且其中,所述方法还包括:
    针对各个上层块链式层,根据相同或者不同的上层块链式层生成条件,基于该上层块链式层生成该上层块链式层的相邻上层块链式层。
  3. 如权利要求1或2所述的方法,其中,上层块链式层生成条件包括:
    底层块链式层中的两个相邻基准区块之间的区块数目达到指定数目;或者
    底层块链式层中的两个相邻基准区块的生成时间间隔达到指定时间间隔。
  4. 如权利要求3所述的方法,其中,多层块链式结构中的各个块链式层中的指定数目或指定时间间隔是相同的或不同的,以及各个块链式层之间的指定数目或指定时间间隔是相同的或不同的。
  5. 如权利要求1或2所述的方法,还包括:
    针对所述多层块链式结构中的各层块链式层,确定新生成的区块是否是满足上层块链式层生成条件的基准区块。
  6. 如权利要求1或2所述的方法,其中,至少部分地基于该基准区块,生成上层块链式层的对应上层区块包括:
    基于从各个块链式层的第一个区块到该基准区块的所有区块中的至少部分区块的区块信息,生成该块链式层的相邻上层块链式层的对应上层区块。
  7. 如权利要求1或2所述的方法,还包括:
    存储基准区块与对应上层区块的区块索引信息。
  8. 如权利要求7所述的方法,其中,所述区块索引信息包括基准区块或对应上层区块的块高。
  9. 如权利要求7所述的方法,其中,所述区块索引信息被包括在基准区块或对应上层区块中,或所述区块索引信息被存储在索引数据库中。
  10. 如权利要求1或2所述的方法,其中,所述多层块链式结构中的各个上层块链式层的头区块包括底层块链式层的创世区块的哈希值。
  11. 一种用于生成多层块链式结构的装置,所述多层块链式结构包括底层块链式层和上层块链式层,所述装置包括:
    底层块链式层生成单元,基于交易数据生成多层块链式结构中的底层块链式层的区块;以及
    上层块链式层生成单元,根据上层块链式层生成条件,基于底层块链式层生成上层块链式层,
    其中,所述上层块链式层生成单元包括:
    基准区块确定模块,确定底层块链式层中是否存在触发上层块链式层生成条件的基准区块;
    上层块链式层生成模块,响应于底层块链式层中存在触发上层块链式层区块生成条件的基准区块,至少部分地基于该基准区块的区块信息,生成上层块链式层的对应上层区块。
  12. 如权利要求11所述的装置,其中,多层块链式结构包括多个上层块链式层,并且其中,所述上层块链式层生成单元还针对各个上层块链式层,根据相同或者不同的上层块链式层生成条件,基于该上层块链式层生成该上层块链式层的相邻上层块链式层。
  13. 如权利要求11或12所述的装置,其中,上层块链式层生成条件包括:
    底层块链式层中的两个相邻基准区块之间的区块数目达到指定数目;或者
    底层块链式层中的两个相邻基准区块的生成时间间隔达到指定时间间隔。
  14. 如权利要求11所述的装置,其中,所述基准区块确定模块针对所述多层块链式结构中的各层块链式层,确定新生成的区块是否是满足上层块链式层生成条件的基准区块。
  15. 如权利要求11或12所述的装置,其中,所述上层块链式层生成模块基于从各个块链式层的第一个区块到该基准区块的所有区块中的至少部分区块的区块信息,生成该块链式层的相邻上层块链式层的对应上层区块。
  16. 如权利要求11或12所述的装置,还包括:
    区块索引信息存储单元,存储基准区块与对应上层区块的区块索引信息。
  17. 如权利要求16所述的装置,其中,所述区块索引信息存储单元将所述区块索引信息存储在基准区块或对应上层区块中,或将所述区块索引信息存储在索引数据库中。
  18. 一种计算设备,包括:
    至少一个处理器;以及
    存储器,所述存储器存储指令,当所述指令被所述至少一个处理器执行时,使得所述至少一个处理器执行如权利要求1到10中任一所述的方法。
  19. 一种机器可读存储介质,其存储有可执行指令,所述指令当被执行时使得所述机器执行如权利要求1到10中任一所述的方法。
PCT/CN2020/124446 2019-12-11 2020-10-28 用于生成多层块链式结构的方法及装置 WO2021114926A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201911267083.XA CN111159286B (zh) 2019-12-11 2019-12-11 用于生成多层块链式结构的方法及装置
CN201911267083.X 2019-12-11

Publications (1)

Publication Number Publication Date
WO2021114926A1 true WO2021114926A1 (zh) 2021-06-17

Family

ID=70556920

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/124446 WO2021114926A1 (zh) 2019-12-11 2020-10-28 用于生成多层块链式结构的方法及装置

Country Status (2)

Country Link
CN (1) CN111159286B (zh)
WO (1) WO2021114926A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111159286B (zh) * 2019-12-11 2023-05-16 支付宝(杭州)信息技术有限公司 用于生成多层块链式结构的方法及装置

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10320569B1 (en) * 2018-04-05 2019-06-11 HOTYB, Inc. Systems and methods for authenticating a digitally signed assertion using verified evaluators
CN110019278A (zh) * 2019-01-31 2019-07-16 阿里巴巴集团控股有限公司 一种数据验证方法、装置及设备
CN110347684A (zh) * 2019-06-28 2019-10-18 阿里巴巴集团控股有限公司 基于区块链的分级存储方法及装置、电子设备
CN110347744A (zh) * 2019-06-03 2019-10-18 阿里巴巴集团控股有限公司 多层块链式账本的数据存储方法、装置及设备
CN111143381A (zh) * 2019-12-11 2020-05-12 支付宝(杭州)信息技术有限公司 用于更新多层块链式结构中的信任点的方法及装置
CN111159286A (zh) * 2019-12-11 2020-05-15 支付宝(杭州)信息技术有限公司 用于生成多层块链式结构的方法及装置

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11095432B2 (en) * 2017-04-05 2021-08-17 Samsung Sds Co., Ltd. System for processing data based on blockchain and operating method thereof

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10320569B1 (en) * 2018-04-05 2019-06-11 HOTYB, Inc. Systems and methods for authenticating a digitally signed assertion using verified evaluators
CN110019278A (zh) * 2019-01-31 2019-07-16 阿里巴巴集团控股有限公司 一种数据验证方法、装置及设备
CN110347744A (zh) * 2019-06-03 2019-10-18 阿里巴巴集团控股有限公司 多层块链式账本的数据存储方法、装置及设备
CN110347684A (zh) * 2019-06-28 2019-10-18 阿里巴巴集团控股有限公司 基于区块链的分级存储方法及装置、电子设备
CN111143381A (zh) * 2019-12-11 2020-05-12 支付宝(杭州)信息技术有限公司 用于更新多层块链式结构中的信任点的方法及装置
CN111159286A (zh) * 2019-12-11 2020-05-15 支付宝(杭州)信息技术有限公司 用于生成多层块链式结构的方法及装置

Also Published As

Publication number Publication date
CN111159286B (zh) 2023-05-16
CN111159286A (zh) 2020-05-15

Similar Documents

Publication Publication Date Title
TWI740423B (zh) 在基於區塊鏈的私有交易中提供隱私和安全保護的系統和方法
US10708060B2 (en) System and method for blockchain-based notification
US11128522B2 (en) Changing a master node in a blockchain system
TWI740378B (zh) 用於進行交易驗證的方法及裝置
WO2021135857A1 (zh) 对信任节点信息进行更新的方法及装置
WO2021135757A1 (zh) 用于执行交易正确性验证的方法及装置
CN115210741B (zh) 部分有序的区块链
WO2021184885A1 (zh) 用于更新区块链节点处的公钥集合的方法及装置
US11061887B2 (en) Event verification receipt system and methods
KR102404284B1 (ko) 디지털 마크를 생성하기 위한 시스템 및 방법
US20200394552A1 (en) Aggregated maching learning verification for database
US20160344737A1 (en) Uniqueness and auditing of a data resource through an immutable record of transactions in a hash history
US11126458B2 (en) Method, apparatus, and electronic device for resource allocation based on blockchain
WO2021135744A1 (zh) 用于区块链节点的数据同步方法及装置
US11580240B2 (en) Protecting sensitive data
US11983608B2 (en) Efficient verification of machine learning applications
US10951417B2 (en) Blockchain-based transaction verification
US20220329411A1 (en) Blockchain processing offload to network device
WO2021114796A1 (zh) 用于更新多层块链式结构中的信任点的方法及装置
US20210406876A1 (en) Permissioned eventing in a decentralized database
WO2021135755A1 (zh) 发送针对数据请求的应答消息的方法及装置、区块链系统
WO2021143364A1 (zh) 获取去中心化应用集群中的交易处理状态的方法及装置
WO2021114926A1 (zh) 用于生成多层块链式结构的方法及装置
US20220166616A1 (en) Key reclamation in blockchain network via oprf
CN111162970B (zh) 在区块链系统中测试去中心化应用服务器的方法及装置

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: 20897873

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20897873

Country of ref document: EP

Kind code of ref document: A1