WO2023221772A1 - 基于区块链网络的数据处理方法及相关产品 - Google Patents

基于区块链网络的数据处理方法及相关产品 Download PDF

Info

Publication number
WO2023221772A1
WO2023221772A1 PCT/CN2023/091997 CN2023091997W WO2023221772A1 WO 2023221772 A1 WO2023221772 A1 WO 2023221772A1 CN 2023091997 W CN2023091997 W CN 2023091997W WO 2023221772 A1 WO2023221772 A1 WO 2023221772A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
network
consensus
target
node
Prior art date
Application number
PCT/CN2023/091997
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 WO2023221772A1 publication Critical patent/WO2023221772A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1464Management of the backup or restore process for networked environments
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1469Backup restoration techniques
    • 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
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof

Definitions

  • This application relates to the field of blockchain technology, and in particular to data processing methods, data processing devices, computer equipment, computer-readable storage media and computer program products based on blockchain networks.
  • Blockchain is the basis of blockchain technology.
  • Blockchain is essentially a decentralized database. It is a series of data blocks generated using cryptographic methods. Each data block contains a batch of network transactions. The information is used to verify the validity of its information (anti-counterfeiting) and generate the next block.
  • the blockchain is usually maintained by the consensus node in the blockchain network, but there may be cases where the block data of the blockchain maintained by the consensus node is lost due to factors such as storage space (such as hard disk) damage. In this case Consensus nodes usually need to recover block data to ensure the integrity of the maintained blockchain. How to complete the recovery of block data is a current research hotspot.
  • the embodiments of this application provide a data processing method and related products based on the blockchain network, which can successfully recover blocks and effectively ensure the availability of the recovered blocks.
  • inventions of the present application provide a data processing method based on a blockchain network.
  • the blockchain network includes a witness network and a consensus network.
  • the witness network is composed of a network of multiple business nodes.
  • the consensus network The network is composed of multiple consensus nodes, and a communication connection is established between the witness network and the consensus network; the method includes:
  • the target block When it is determined that the target block needs to be restored based on the check block of the target block, obtain the check block of the target block from the business node in the witness network; based on the encoding matrix and from the witness network
  • the check block obtained by the service node determines the data recovery reference matrix; the target block is restored based on the data recovery reference matrix and the check block obtained from the service node in the witness network; wherein, the The target block is a block on the blockchain maintained by the consensus node in the consensus network; the check block of the target block stored by the business node is the block obtained by the business node from the consensus network. It is obtained when the consensus node synchronizes the relevant block data of the target block; the verification block is obtained by encoding the target block by the consensus node in the consensus network using the encoding matrix; the verification block The verification block is used to recover the target block.
  • inventions of the present application provide another data processing method based on a blockchain network.
  • the blockchain network includes a witness network and a consensus network.
  • the witness network is composed of a network of multiple business nodes.
  • the consensus network is composed of a plurality of consensus nodes, and a communication connection is established between the witness network and the consensus network; the method includes:
  • the block synchronization request carries the synchronization block height and the node identification of the target business node; the synchronization block height is the block of the target block that needs to be synchronized height, the target block is a block on the blockchain maintained by the consensus node in the consensus network; the block synchronization request uses Requesting the consensus node to return the relevant data of the target block; receiving the relevant data of the target block returned by the consensus node; the relevant data includes the block header of the target block, the target area
  • the coding matrix is obtained by encoding the target block; K is a positive integer greater than 1; the relevant data of the target block is stored; wherein the stored matching check block is used for consensus in the consensus network Used when the node restores the target block.
  • inventions of the present application provide a data processing device.
  • the data processing device is applied in a blockchain network.
  • the blockchain network includes a witness network and a consensus network.
  • the witness network consists of multiple business nodes.
  • the consensus network is composed of a plurality of consensus nodes, and a communication connection is established between the witness network and the consensus network; the device includes:
  • a processing unit configured to obtain the verification block of the target block from the service node in the witness network through a transceiver unit when it is determined that the target block needs to be restored based on the verification block of the target block;
  • the processing unit is also configured to determine the data recovery reference matrix based on the coding matrix and the check block obtained from the service node in the witness network;
  • the processing unit is also configured to recover the target block based on the data recovery reference matrix and the check block obtained from the service node in the witness network;
  • the target block is a block on the blockchain maintained by the consensus node in the consensus network;
  • the check block of the target block stored by the business node is the block on which the business node is located. It is obtained when the consensus node in the consensus network synchronizes the relevant block data of the target block;
  • the verification block is obtained by encoding the target block by the consensus node in the consensus network using the encoding matrix. ;
  • the check block is used to restore the target block.
  • inventions of the present application provide another data processing device, which is applied in a blockchain network.
  • the blockchain network includes a witness network and a consensus network.
  • the witness network is composed of multiple businesses.
  • the consensus network is composed of a plurality of consensus node networks, and a communication connection is established between the witness network and the consensus network; the device includes:
  • a processing unit configured to send a block synchronization request to a consensus node in the consensus network through a transceiver unit; the block synchronization request carries the synchronization block height and the node identification of the target business node; the synchronization block height is required The block height of the synchronized target block, which is a block on the blockchain maintained by the consensus node in the consensus network; the block synchronization request is used to request the consensus node to return the Relevant data of the target block;
  • the transceiver unit is also used to receive relevant data of the target block returned by the consensus node; the relevant data includes the block header of the target block, the target business node included in the target block The transaction data with access rights and the matching check block that matches the node identification among the K check blocks corresponding to the target block; the K check blocks are the target block using a coding matrix. Obtained by encoding; K is a positive integer greater than 1;
  • a storage unit configured to store relevant data of the target block; wherein the stored matching verification block is used by the consensus node in the consensus network to restore the target block.
  • embodiments of the present application provide a computer device, including: a processor, a communication interface, and a memory.
  • the processor, the communication interface, and the memory are connected to each other, and the memory stores an executable program.
  • Code the processor is configured to call the executable program code to implement the data processing method based on the blockchain network provided by the embodiment of the present application.
  • embodiments of the present application also provide a computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When run on a computer, the computer implements the block-based method provided by the embodiments of the present application. chain Network data processing methods.
  • embodiments of the present application also provide a computer program product.
  • the computer program product includes a computer program or computer instructions.
  • the area-based method provided by the embodiments of the present application is implemented.
  • Data processing method of blockchain network is implemented.
  • the consensus node generates the verification block of the block, and when the business node synchronizes the block, the verification block of the block and the relevant block data of the block are synchronized to the business node, and when the consensus node
  • the consensus node When a block needs to be restored, the verification block of the block that needs to be restored is obtained from the business node, and the block can be successfully restored based on the obtained verification block.
  • the consensus network when the consensus network is in an unavailable state and the block recovery cannot be completed based on the block data stored by the business node, the block can also be successfully recovered based on the verification block stored by the business node, and can effectively guarantee Availability of recovered blocks.
  • Figure 1a is a schematic structural diagram of a blockchain provided by an embodiment of the present application.
  • Figure 1b is a schematic architectural diagram of a data sharing system provided by an embodiment of the present application.
  • Figure 2a is a schematic diagram of the architecture of a hierarchical blockchain network provided by an embodiment of the present application.
  • Figure 2b shows the isolation between transaction data of different businesses in the hierarchical blockchain network shown in Figure 2a;
  • Figure 3a shows the check block distribution process involved in the embodiment of the present application
  • FIG. 3b shows the block recovery process involved in the embodiment of the present application
  • FIG. 4 shows the process of the check block generation and storage stages involved in the embodiment of the present application
  • Figure 5 shows the check block generation method involved in the embodiment of the present application
  • Figure 6 shows the process of the block data and check block synchronization phase involved in the embodiment of the present application
  • Figure 7 shows the process of the block recovery phase involved in the embodiment of the present application
  • Figure 8 is a schematic diagram of a data recovery reference matrix provided by an embodiment of the present application.
  • Figure 9 is a schematic diagram of a data matrix provided by an embodiment of the present application.
  • Figure 10 is a schematic structural diagram of a data processing device provided by an embodiment of the present application.
  • FIG. 11 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
  • Consensus node The consensus node in the blockchain network is responsible for generating blocks. In addition to packaging a batch of transactions, the consensus node In addition to executing transactions, it is also responsible for reaching consensus with other consensus nodes to update the chain status. The consensus node has the full amount of blockchain data.
  • the upper-level node synchronizes transactions with the lower-level nodes based on the permissions of the lower-level nodes.
  • the business node is a lightweight node in the blockchain network.
  • the business node is responsible for processing business requests and transparently transmitting the business requests to the consensus node; the business node synchronizes all block headers and only synchronizes the Transaction data that is visible to the node (that is, has access rights); the business node initiates a synchronization request to the consensus node or the superior node of the business node, and the consensus node or superior node clears the block header and transaction data visible to the business node to the business node.
  • Merkle tree is a typical binary tree structure, consisting of a root node (ie, Merkle tree root), a set of intermediate nodes and a set of leaf nodes. The lowest leaf node stores the data or its hash value, and the other nodes store the hash values of the contents of its two child nodes.
  • Pbft consensus algorithm (that is, a consensus algorithm based on a practical Byzantine fault-tolerant algorithm): It is a consensus algorithm based on message passing. The algorithm reaches consistency through three stages. When there are f Byzantine fault nodes, if the total number of nodes is greater than or equal to 3f+1, all nodes can still reach a final consensus (that is, consensus can be completed); conversely, if the total number of nodes is less than 3f+1, all nodes cannot reach a final consensus. Unanimous (i.e. consensus cannot be achieved).
  • Erasure coding technology mainly encodes the original data to obtain redundancy through the erasure coding algorithm, and stores the data and redundancy together to achieve the purpose of fault tolerance.
  • the basic idea is to obtain m blocks of redundant elements (check blocks) from n blocks of original data elements through certain calculations. For these n+m blocks of elements, when any of the m block elements makes an error (including original data and redundant data), the original n blocks of data can be restored through the corresponding reconstruction algorithm.
  • the embodiments of this application relate to blockchain (Blockchain) technology, which is the basis of blockchain technology.
  • the so-called blockchain is a new application model of distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm and other computer technologies.
  • Blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of the information. (anti-counterfeiting) and generate the next block.
  • the structural diagram of a blockchain can be seen in Figure 1a. As shown in Figure 1a, the blockchain 101 is composed of multiple blocks. The first block of the blockchain is called the genesis block (which can be referred to as the genesis block for short).
  • the genesis block includes a block header and a block body.
  • the block header stores the input information feature value, version number, timestamp and difficulty value, and the block body stores input information (including transaction data); Creation
  • Creation The next block of the world block has the genesis block as the parent block.
  • the next block also includes a block header and a block body.
  • the block header stores the input information characteristic value of the current block and the block header of the parent block. Feature value, version number, timestamp and difficulty value, and so on, make the block data stored in each block in the blockchain related to the block data stored in the parent block, ensuring that the block The security of information entered into.
  • the blockchain can be maintained by the blockchain nodes included in the blockchain network; among them, the blockchain network can be understood as a data sharing system, which refers to the data sharing between blockchain nodes.
  • a system an exemplary structure of the data sharing system can be seen in Figure 1b; as shown in Figure 1b, the data sharing system can include multiple blockchain nodes 102, and each blockchain node 102 can be connected to the
  • the server in the blockchain network can also be a terminal device (such as a client) connected to the blockchain network.
  • the specific form of the blockchain node 102 is not limited here.
  • Each blockchain node 102 in the blockchain network has a corresponding node identifier, and each blockchain node 102 in the blockchain network can store other blockchains in the blockchain network.
  • the node identifier of the node 102 is used to subsequently broadcast the generated block to other blockchain nodes 102 in the data sharing system based on the node identifiers of other blockchain nodes 102.
  • Each blockchain node 102 can maintain a node identification list, and store the node name and the node identification correspondingly in the node identification list; where, the node identification list can be seen in Table 1:
  • the node identifier can be an IP (Internet Protocol, a protocol for interconnection between networks) address and any other information that can be used to identify the node; for example, the node identifier can also be a binary sequence code (such as 110001110 ), Table 1 only takes the IP address as an example for explanation.
  • IP Internet Protocol, a protocol for interconnection between networks
  • Table 1 only takes the IP address as an example for explanation.
  • the blockchain network shown in Figure 1b is a single-layer blockchain network, that is, the nodes are peer-to-peer and are in the same network. But when the blockchain network is used in some application scenarios such as government or commercial institutions, not all blockchain participating nodes have enough resources and necessity to become nodes participating in the blockchain consensus; Considering the security of data, when confidential data is involved in the blockchain system, it is not advisable to adopt the general data parity blockchain deployment method. It can be seen that the single-layer (i.e. node peer-to-peer) blockchain network is not suitable for the above-mentioned application scenarios.
  • the blockchain network is divided into two layers: a witness network and a consensus network.
  • the witness network is composed of multiple business nodes.
  • the consensus network is composed of multiple consensus nodes, and a communication connection is established between the witness network and the consensus network.
  • the business nodes in the witness network are lightweight nodes, and the consensus nodes in the consensus network are full-weight nodes.
  • Consensus nodes participate in block generation (i.e.
  • each consensus node has a full amount of blockchain data, or stores the block data of all blocks on the blockchain; business nodes Execute business logic in the witness network, submit business operations to the consensus network, synchronize block data from the consensus node (synchronize all block headers, and only synchronize transaction data visible to the node (or have access rights)), etc.
  • the witness network and the consensus network are in different network environments.
  • the witness network is usually in a public network, and the joining/exiting of business nodes is relatively free; while the consensus network is usually deployed in a relatively secure and closed private network, and the joining/exiting of consensus nodes is relatively free. Exit requires the consensus of the consensus committee (or all consensus nodes in the consensus network).
  • the hierarchical blockchain network shown in Figure 2a is a system of consensus nodes + business nodes, which can achieve isolation between transaction data of different businesses, as shown in Figure 2b; in addition, in addition to storing the full amount of transaction data in the consensus network
  • the consensus node will also sort business-related transaction data to business nodes based on the permissions of the business nodes.
  • the design of this hierarchical blockchain meets the industry's requirements for transaction confidentiality and also enhances the availability of blockchain data to a certain extent. Even if there is a situation where the consensus network data is untrustworthy/unavailable, the data stored on the business nodes Historical transaction data can still be queried.
  • each node in the blockchain network can be distinguished according to different functions (divided into consensus nodes and business nodes).
  • a hierarchical blockchain network can be realized. And only some nodes in the blockchain network need to be used as consensus nodes, which will help improve consensus efficiency; on the other hand, nodes in different networks can store different data and realize a blockchain deployment method with data asymmetry, so Can improve data security and confidentiality.
  • hierarchical blockchain networks can be applied to application scenarios where single-layer blockchain networks are not suitable.
  • the business nodes in the witness network may store the block data of block B
  • consensus node A or consensus node C can try to obtain all the block data of block B from the business nodes in the witness network. If from the witness network The business node in can obtain all the block data of block B, and then block B can be directly restored based on the obtained all block data of block B. If, for example, the business nodes in the witness network are unable to synchronize all the block data of block B (for example, the transaction data in block B is not visible to all business nodes), the business nodes can only synchronize block B.
  • consensus node A or consensus node C cannot obtain all the block data of block B from the business nodes in the witness network. At this time, consensus node A or consensus node C cannot obtain block B.
  • embodiments of the present application provide a block recovery solution, which is used when the consensus network is in an unavailable state (that is, the consensus nodes in the consensus network are unable to reach a consistent consensus), and based on the business nodes in the witness network stored When the block data cannot be restored, the block can be successfully restored, and the availability (or accuracy) of the restored block can be effectively guaranteed.
  • the block recovery solution provided by the embodiment of the present application mainly includes a check block distribution process as shown in Figure 3a and a block recovery process through check blocks as shown in Figure 3b.
  • the consensus node generates the verification block for each block on the blockchain.
  • the business node normally synchronizes the block data from the consensus node, in addition to synchronizing the transaction data and block headers related to the business node in a block, additional synchronization is required.
  • the check block for this block.
  • the consensus node needs to restore a block through a verification block
  • the consensus node requests the verification block from the business node, and after collecting a sufficient number of verification blocks, the block can be successfully restored based on the obtained verification block. block data.
  • the block recovery scheme provided by the embodiment of this application is illustrated with the above-mentioned example of recovering block B.
  • the main processing flow is as follows: after each consensus node in the consensus network uploads block B to the chain, it uses a coding matrix to B is encoded to obtain K check blocks of block B. K is a positive integer greater than 1. The K check blocks are used to restore block B; then all or part of the K check blocks are stored.
  • consensus node A or consensus node C can obtain each verification block of block B from the business node in the witness network, and then based on the coding matrix and the witness
  • Each check block of block B obtained by the business node in the certification network determines the data recovery reference matrix; finally, based on the data recovery reference matrix and the obtained each check block of block B, the area can be successfully restored.
  • the block recovery scheme provided by the embodiment of the present application has been briefly introduced above.
  • the block recovery scheme ie, the data processing method described below.
  • the data processing method provided by the embodiment of this application is implemented based on the hierarchical blockchain network shown in Figure 2a.
  • the data processing method includes a verification block generation and storage stage, a block data and verification block synchronization stage, and a block recovery stage. There are three stages. The processing flow of each stage is described in detail below.
  • the verification block generation and storage phase is implemented by the target consensus node in the consensus network (any consensus node in the consensus network). Please refer to Figure 4.
  • Figure 4 shows the processing flow of the check block generation and storage stage included in the data processing method provided by the embodiment of the present application.
  • the check block generation and storage stage includes but is not limited to the following steps:
  • the first block is any block on the blockchain (that is, the blockchain maintained by the consensus node in the consensus network), and N is a positive integer greater than 1.
  • Serialization refers to breaking down data into a stream of bytes. After the serialization of the first block is completed, the byte stream obtained by the serialization is split to obtain a total of N data blocks D 1 , D 2 ,..., D N . Among them, the byte stream obtained by serialization can be split according to equal data amounts to obtain N data blocks. Of course, it can also be split according to unequal data amounts. The embodiment of the present application does not limit the splitting method.
  • the subscript of the data block D i (i is any one from 1 to N) can indicate the order of the corresponding data block in the serialization processing result.
  • the data block identified as D 1 is the serialization processing result.
  • the data block identified as D 3 can be serialized. The first block of data in the result.
  • S402. Form the N data blocks obtained by splitting into an N*1 data block matrix.
  • the data block matrix is shown as 504 in Figure 5.
  • the encoding matrix uses the encoding matrix to encode the data block matrix to obtain an encoding result; the encoding result includes K check blocks and N data blocks obtained by splitting; K is a positive integer greater than 1.
  • the encoding matrix may be constructed based on the Vandermond matrix, and any W*H sub-matrix of the encoding matrix is invertible.
  • the coding matrix may be concatenated by an N*N identity matrix and a K*N coding parameter matrix.
  • the form of the coding matrix may be as shown in 501 in Figure 5, including an N*N unit matrix shown in 502, a K*N coding parameter matrix shown in 503, and M 11 , M 12 , shown in 503 . . , M KN
  • the specific values of the total K*N encoding parameters are defined by the target consensus node, as long as it can ensure that any W*H sub-matrix of the encoding matrix is invertible after definition.
  • W is a positive integer greater than or equal to 1 and less than or equal to K+N
  • H is a positive integer greater than or equal to 1 and less than or equal to N.
  • W and H may or may not be equal; K may be equal to N. , may also be unequal to N.
  • using the encoding matrix to encode the data block matrix may involve matrix multiplication of the encoding matrix and the data block matrix.
  • the encoding result shown in 505 is obtained.
  • the encoding result is a (N+K)*1 matrix, and the first N elements of the matrix are are the N data blocks D 1 , D 2 ,..., D N of the first block, and the last K elements of the matrix are the check blocks C 1 , C 2 , generated for the N data blocks.
  • each check block C i (i is any one of 1-k) is generated based on a row element of the above coding parameter matrix and the N data blocks, such as check Block C 1 is based on the first row elements of the coding parameter matrix (M 11 , M 12 , ..., M 1N ) and the data block matrix (D 1 , D 2 , ..., D N ) is obtained, that is, the check block C 1 has a corresponding relationship with the first row elements (M 11 , M 12 , ..., M 1N ) of the coding parameter matrix.
  • the rest of the situation is similar, in This will not be described again.
  • the target consensus node can store all K verification blocks of the first block.
  • K is relatively large (such as 100000)
  • each consensus node in the consensus network will use the above
  • the method generates K verification blocks for the first block. If each consensus node stores all K verification blocks of the first block, data redundancy will occur.
  • the K verification blocks of the first block can be stored in multiple consensus nodes in the consensus network. At this time, the target consensus node only needs to store the K verification blocks of the first block. Part of the check block in the check block is sufficient.
  • the consensus network is composed of G (G is a positive integer greater than 1) consensus nodes
  • G can be used as the value of K, that is, K and G are equal.
  • the target consensus node can determine the check block whose arrangement ID matches the target consensus node's arrangement ID in the consensus network from the K check blocks of the first block, and only store the matching check block.
  • the subscript of the check block C i is its arrangement identifier, which is used to indicate the arrangement order of the check blocks among the K check blocks.
  • the consensus nodes in the consensus network also have arrangement identifiers used to indicate their arrangement order. Assuming that the arrangement identifier of the target consensus node indicates that its arrangement order in the consensus network is No.
  • the target consensus node can use the check block C 2 as a matching check block and only store the check block C 2 .
  • each consensus node in the consensus network will store one of the K verification blocks of the first block, and different consensus nodes store different verification blocks for the first block.
  • K and G are equal, and N and G are also equal, that is, K, N and G are equal.
  • W and H are also equal.
  • steps S401 to S404 may be executed by the target consensus node after the first block is uploaded to the chain (or stored on the blockchain).
  • a hash calculation can be performed on each of the K check blocks to obtain K hash values; and then based on The calculated K hash values construct a Merkle tree, and the root of the constructed Merkle tree (Merkle tree root) is added to the block header of the second block; the second block is the block The block next to the first block on the chain, that is, the block with a block height that is 1 greater than the first block.
  • the Merkle tree root can be added to the block header of the second block. At this time, the above steps can be executed by the target consensus node. .
  • the Merkle tree root can also participate in the calculation of the hash value of the block header of the second block.
  • the above steps are executed by the block producing node of the second block (which can be the target consensus node or other consensus nodes in the consensus network).
  • each consensus node in the consensus network will perform steps S401 to S404 for each block on the blockchain to complete the generation and storage of the verification block of each block. Please refer to the above description for specific implementation methods and will not be repeated here.
  • the encoding matrices used by different consensus nodes are the same; while the encoding matrices used for different blocks can be the same or different.
  • the block data and verification block synchronization phase is jointly executed by the target business node in the witness network (any business node in the witness network) and the target consensus node in the consensus network.
  • Figure 6 shows the processing flow of the block data and check block synchronization stage included in the data processing method provided by the embodiment of the present application.
  • the block data and check block synchronization stage includes but is not limited to the following step:
  • the target business node sends a block synchronization request to the target consensus node in the consensus network.
  • the block synchronization request carries the synchronization block height and the node identification of the target business node.
  • the target consensus node can be any consensus node in the consensus network, or it can be the consensus node closest to the target business node in the consensus network.
  • the nearest means the shortest distance, or the shortest communication time.
  • the target consensus node can also be a consensus node that the target business node in the consensus network has access rights to.
  • the synchronization block height is the block height of the target block that needs to be synchronized, and the target block is the block on the blockchain maintained by the consensus node in the consensus network; the block synchronization request is used to request the target consensus node to return the target Block related data.
  • the target consensus node responds to the block synchronization request and determines the matching block that matches the height of the synchronized block from the blockchain.
  • the target consensus node can query the block whose block height is the synchronization block height from the blockchain, and determine the block whose block height is the synchronization block height as the matching block.
  • the matching block is the target block that the above-mentioned target business node needs to synchronize.
  • the target consensus node obtains the block header of the matching block and the transaction data included in the matching block that the target business node has access rights to.
  • the target consensus node obtains the block header of the matching block, and detects whether there is transaction data included in the block body of the matching block that the target business node has access rights to. If there is, then from the matching block Obtain the transaction data that the target business node has access rights from in the block body of the block. Otherwise, if it does not exist, the transaction data will not be obtained.
  • the target consensus node obtains the matching check block that matches the node identifier of the target business node among the K check blocks corresponding to the matching block.
  • the K check blocks corresponding to the matching block are generated and stored in the consensus node in the consensus network during the above-mentioned check block generation and storage stage.
  • the target consensus node can determine a value V based on the node identification of the target business node, and then compare the subscript values in the K check blocks C 1 , C 2 ,..., C K corresponding to the matching block with this value VThe same check block is determined as the matching check block. If the target consensus node itself stores the matching verification block, it will obtain the matching verification block directly from its own storage space; otherwise, if the target consensus node does not store the matching verification block, it will obtain the matching verification block from other consensus nodes in the consensus network. Obtain the matching verification block at the node.
  • id represents the node identification of the target business node
  • Hash represents the hash operation
  • mod represents the modulo operation
  • the K verification blocks (all or part) of the target block can be distributed and stored in multiple business nodes in the witness network, so that when the target block needs to be restored based on the verification blocks in the future, it is effectively guaranteed to be able to recover from the witness network.
  • a sufficient number of verification blocks of the target block are obtained from the business nodes of the network, thereby ensuring the recovery success rate of the target block.
  • the target consensus node sends the block header of the matching block, the transaction data included in the matching block that the target business node has access rights to, and the matching verification block to the target business node.
  • the target business node stores the block header of the matching block (ie, the target block), the transaction data included in the matching block that the target business node has access rights to, and the matching verification block.
  • the block header of the reference block synchronized from the consensus node in the consensus network is first obtained.
  • the reference block is the target block (i.e., the matching block) on the blockchain.
  • the root of the Merkle tree The method of adding the root to the block header of the reference block can be referred to the previous description and will not be repeated here.
  • the stored matching verification block is used by the consensus node in the consensus network to restore the target block.
  • the target consensus node can also obtain the Merkle path of the matching verification block, that is, from the root node of the tree to the Merkle path corresponding to the matching verification block in the Merkle tree constructed based on the K verification blocks corresponding to the target block.
  • the path of the node and send the Merkle path matching the verification block to the target business node.
  • the target business node can detect whether the matching check block and the Merkle path of the matching check block match the root of the Merkle tree included in the reference block. If they match, the matching check block and the Merkle path are stored. Merkle path matching the checksum block.
  • multiple (or even every) business node in the witness network will synchronize relevant data for each block on the blockchain based on the above method. If the business node synchronizes relevant data for a certain area The transaction data in the block does not have access rights, then only the block header and the check block matching the business node ID among the K check blocks of the block are synchronized; if the business node has no access rights to the transaction in a block, If the data has access rights, then the block header, the transaction data with access rights, and the check block matching the business node ID among the K check blocks of a certain block are synchronized.
  • the block data (all or part) of each block on the blockchain and the K verification blocks (all or part) of each block can be distributed and stored in multiple business nodes in the witness network.
  • the K verification blocks (all or part) of each block can be distributed and stored in multiple business nodes in the witness network.
  • the block recovery phase is jointly executed by the target consensus node in the consensus network and the business node in the witness network.
  • the target consensus node at this time can be a block in the consensus network due to factors such as damage to the storage space (such as a hard disk). Block data is lost and the consensus node needs to restore the block; it can also be a node that newly joins the consensus network and becomes a consensus node and needs to synchronize all block data.
  • Figure 7 shows the processing flow of the block recovery phase included in the data processing method provided by the embodiment of the present application.
  • the block recovery phase includes but is not limited to the following steps:
  • the target block is the block that needs to be restored, and can be any block on the blockchain. If it is detected that the target consensus node needs to restore the target block, and the proportion of abnormal consensus nodes in the consensus network exceeds the set proportion, and the business nodes in the witness network do not store all the block data of the target block, then it is determined A check block based on the target block is needed to restore the target block.
  • abnormal consensus nodes refer to consensus nodes that are unable to participate in (or complete) consensus due to reasons such as related data loss or disconnection.
  • the setting ratio can be, for example, 1/2 or 1/3, etc., and the setting The value of the ratio can be determined based on consensus rules.
  • the consensus nodes in the consensus network cannot reach a consistent consensus, and the consensus network is in an unavailable state.
  • the correctness (or availability) of the target block stored by other consensus nodes cannot be determined, and the target block cannot be directly synchronized from other consensus nodes.
  • the only way to restore the target block is to use the verification block based on the target block.
  • the target consensus node obtains the check block of the target block from the business node in the witness network.
  • the specific method can be: the target consensus node obtains the check block of the target block from the business node in the witness network.
  • the business node broadcasts a verification block acquisition request for the target block, and the verification block acquisition request can carry the block height of the target block.
  • the business node of the witness network After the business node of the witness network receives the verification block acquisition request, it queries whether the verification block of the target block is stored. If the verification block of the target block is stored, the stored verification block of the target block is sent. to the target consensus node.
  • the check block acquisition request not only indicates the need to acquire the check block of the target block, but also indicates the need to acquire the block header of the reference block.
  • the reference block is the next block after the target block on the blockchain, that is, the block height is 1 greater than the target block; the block header of the reference block includes K verification blocks based on the target block. roots of the Merkel tree.
  • the target consensus node obtains the check block of the target block and the block header of the reference block from the business node in the witness network, it detects whether the check block is consistent with the root of the Merkle tree included in the block header of the reference block. If they match, the check block is determined to be valid and can be used to restore the target block; otherwise, if it does not match, the check block is discarded. This can improve the accuracy of the recovered target block, avoid useless repeated operations, and improve the recovery efficiency of the target block.
  • the verification block acquisition request in addition to indicating the need to obtain the verification block of the target block and the block header of the reference block, also indicates the need to obtain the Merkle path of the verification block of the target block.
  • the Merkle path is the path from the tree root node to the node corresponding to the check block in the Merkle tree constructed based on the K check blocks corresponding to the target block. It is the area where the business node synchronizes the target block from the consensus node. Obtained when block data is obtained.
  • the target consensus node obtains the verification block of the target block, the Merkle path of the verification block, and the block header of the reference block from the business node in the witness network, it detects whether the verification and its Merkle path are consistent with the reference block.
  • the root of the Merkle tree included in the block header matches. If it matches, it is determined that the check block is valid and can be used to restore the target block; otherwise, if it does not match, the check block is discarded.
  • the data recovery reference matrix is determined based on the coding matrix and the valid check block obtained from the service node in the witness network.
  • Method 1 When all K check blocks of the target block are obtained from the business nodes in the witness network, and all K check blocks are valid, the corresponding K check blocks are obtained from the encoding matrix corresponding to the target block. matrix elements, and determine the data recovery reference matrix based on the obtained matrix elements corresponding to the K check blocks.
  • each of the K check blocks C i (i is any one of 1-K) is based on a row element of the coding parameter matrix included in the coding matrix and N of the target block.
  • the check block C 1 is based on the first row elements of the coding parameter matrix (M 11 , M 12 ,..., M 1N ) and the data block matrix (D 1 , D 2 ,..., D N ) is obtained, that is, the check block C 1 and the first row element of the coding parameter matrix (M 11 , M 12 ,..., M 1N ) has a corresponding relationship. That is to say, the matrix elements corresponding to the K check blocks in the coding matrix are the elements in the coding parameter matrix included in the coding matrix, and the coding parameter matrix (503 in Figure 5) can be directly determined as data Restore reference matrix.
  • the coding parameter matrix is a sub-matrix of the coding matrix, and the data recovery reference matrix determined in this way is an invertible matrix.
  • K and N are equal, and the determined data recovery reference matrix at this time is a K*K (or N*N) sub-square matrix of the encoding matrix. This can effectively ensure the reversibility of the data recovery reference matrix.
  • K and N may be equal to M (the number of consensus nodes in the consensus network).
  • Method 2 when only X (X is less than K) valid verification blocks among the K verification blocks of the target block are obtained from the business nodes in the witness network, from other consensus nodes in the consensus network (any storage A consensus node with a complete target block) obtains the target block. Since the consensus nodes in the consensus network cannot reach a consistent consensus at this time, the correctness (or availability) of the target block stored by other consensus nodes cannot be determined, so it cannot Directly use the target block obtained from other consensus nodes.
  • the X check blocks in the coding parameter matrix can be obtained based on the correspondence between the check block C i (i is any one of 1-K) and the row elements of the coding parameter matrix included in the coding matrix.
  • the row elements corresponding to the check block; according to the KX data blocks, the data block matrix composed of the N data blocks (i.e., the data block matrix composed of N data blocks for the target block in the check block generation and storage phase, such as 504 in Figure 5 is the row position in an N*1 data block matrix composed of the N data blocks in the check block stage of the target block, and obtains the N*N unit matrix included in the encoding matrix. (502 in Figure 5); then determine based on the row elements corresponding to the X check blocks in the obtained encoding parameter matrix and the row elements corresponding to the KX data blocks in the N*N unit matrix Data recovery reference matrix.
  • the data recovery reference matrix 801 includes There are two parts: 802 and 803.
  • 802 is composed of the second, N-1 and Nth row elements corresponding to the data blocks D 2 , D N-1 and D N in the identity matrix shown as 502 in Figure 5.
  • 803 is composed of
  • the coding parameter matrix shown at 503 in Figure 5 is composed of the elements in the first to Xth rows corresponding to the data block check blocks C 1 , C 2 ,..., C X .
  • the data recovery reference matrix determined using the above method is a sub-matrix of the encoding matrix, so the determined data recovery reference matrix is an invertible matrix.
  • K and N are equal, and the determined data recovery reference matrix at this time is a K*K (or N*N) sub-square matrix of the encoding matrix. This can effectively ensure the reversibility of the data recovery reference matrix.
  • K and N can be equal to G (the number of consensus nodes in the consensus network).
  • the target block is recovered based on the data recovery reference matrix and the valid check block obtained from the business node in the witness network.
  • step S702 corresponds to the above two implementation methods of determining the data recovery reference matrix.
  • Method 1 After determining the data recovery reference matrix using the above method 1, determine the inverse matrix of the data recovery reference matrix, and then recover based on the inverse matrix of the data recovery reference matrix and the obtained K check blocks of the target block. target block.
  • the obtained K check blocks of the target block are arranged into a K*1 data matrix (for example, shown as 901 in Figure 9), and the inverse matrix of the data recovery reference matrix and the check block are By matrix multiplication of the check block matrix, the data block matrix (D 1 , D 2 ,..., D N ) composed of N data blocks of the target block can be obtained, and then based on the data block matrix (D 1 , D 2 ,..., D N ) to recover the complete target block.
  • Method 2 After determining the data recovery reference matrix using the above method 2, determine the inverse matrix of the data recovery reference matrix, and then based on the inverse matrix of the data recovery reference matrix, the obtained X check blocks of the target block and the random The obtained K-X data blocks of the target block are restored to obtain the target block.
  • the randomly acquired KX data blocks of the target block and the acquired X check blocks of the target block are arranged into a K*1 data matrix (as shown at 902 in Figure 9, corresponding to Determined by the example in method 2 above), perform matrix multiplication of the inverse matrix of the data recovery reference matrix and the check block matrix to obtain the target block
  • the data block matrix (D 1 , D 2 ,..., D N ) composed of N data blocks is then based on the data block matrix (D 1 , D 2 ,..., D N ) to recover the complete target block.
  • the target block recovered based on the inverse matrix of the data recovery reference matrix, X check blocks and K-X data blocks can be detected, and the target block recovered from the consensus network Whether the target block obtained by the consensus node in The block is also incorrect (even the block cannot be recovered at all in this case).
  • the target block stored in it can be obtained from other consensus nodes (different from the previous consensus node) and the target block can be recovered using the above method. blocks until the recovered target block is consistent with the target block obtained from the consensus node.
  • the stored target blocks can be obtained from multiple consensus nodes each time, and the block with the largest proportion among the multiple target blocks obtained can be processed, for example, obtained from 5 consensus nodes. If four of the stored target blocks are the same and another block is different, then the same block will be processed. This can ensure the accuracy of the obtained target block to a certain extent and ensure the success of the recovery of the target block.
  • P represents the data block matrix composed of N data blocks of the block
  • P′ represents the data matrix arranged into the K check blocks obtained in the above method 1, or represents the KX randomly obtained in the above method 2.
  • L represents the data recovery reference matrix determined above
  • L′ (-1) represents the inverse matrix of L
  • L′*L′ (-1) is Identity matrix.
  • P′ P*L′, if the data recovery reference matrix shown in Figure 8 is multiplied by the data block matrix composed of N data blocks shown as 504 in Figure 5, we can get the data shown as 902 in Figure 9
  • the KX data blocks obtained randomly and the X check blocks obtained are arranged into a data matrix.
  • the target consensus node can recover all its missing blocks.
  • the target consensus node is a newly added consensus node, it can also complete the synchronization of all blocks on the blockchain.
  • the embodiment of this application provides a solution based on erasure coding to ensure the availability of blockchain data, which can ensure that confidential transactions on the blockchain will not be exposed to consensus nodes
  • Any other node (the business node can only synchronize its visible transactions) can also use the block data stored in the business node to complete the recovery of the block based on the block data stored in the business node when the consensus network is unavailable.
  • the verification block successfully recovers the block and can effectively ensure the availability of the recovered block.
  • the execution body used to execute each step in the above method embodiment may be composed of hardware, software, or a combination of software and hardware.
  • related data such as blockchain, block, block header, block body, transaction data, etc. are involved, and the data used are all authorized by the user.
  • the data used requires user permission or consent, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
  • FIG. 10 is a schematic structural diagram of a data processing device provided by an embodiment of the present application.
  • the device described in the embodiment of this application includes a processing unit 1001, a transceiver unit 1002 and a storage unit 1003.
  • the data processing device is applied in a blockchain network.
  • the blockchain network includes a witness network and a consensus network.
  • the witness The network is composed of a plurality of business nodes, the consensus network is composed of a plurality of consensus nodes, and a communication connection is established between the witness network and the consensus network.
  • the data processing device may be a target consensus node corresponding to the consensus network described above, where:
  • the processing unit 1001 is configured to obtain the target block from the service node in the witness network through the transceiver unit 1002 when it is determined that the target block needs to be restored based on the check block of the target block.
  • Check block
  • the processing unit 1001 is also configured to determine a data recovery reference matrix based on the coding matrix and the check block obtained from the service node in the witness network;
  • the processing unit 1001 is also configured to restore and obtain the target block based on the data recovery reference matrix and the check block obtained from the service node in the witness network;
  • the target block is a block on the blockchain maintained by the consensus node in the consensus network;
  • the check block of the target block stored by the business node is the block on which the business node is located. It is obtained when the consensus node in the consensus network synchronizes the relevant block data of the target block;
  • the verification block is obtained by encoding the target block by the consensus node in the consensus network using the encoding matrix. ;
  • the check block is used to restore the target block.
  • the processing unit 1001 is also configured to, if it is detected that the target block needs to be restored, and the proportion of abnormal consensus nodes in the consensus network exceeds a set proportion, and the witness If the service node in the network does not store all the block data of the target block, it is determined that the target block needs to be restored based on the check block of the target block.
  • the number of check blocks of the target block is K, and K is a positive integer greater than 1;
  • the processing unit 1001 is based on the coding matrix and the check blocks obtained from the service nodes in the witness network.
  • the block determines the data recovery reference matrix. When the target block is recovered based on the data recovery reference matrix and the check block obtained from the service node in the witness network, it is specifically used for:
  • matrix elements corresponding to the K check blocks are obtained from the encoding matrix; based on the obtained K check blocks
  • the matrix element corresponding to the check block determines the data recovery reference matrix, and determines the inverse matrix of the data recovery reference matrix; the target block is recovered based on the inverse matrix of the data recovery reference matrix and the K check blocks .
  • the target block is obtained from the consensus node in the consensus network;
  • X is a positive integer less than K;
  • the obtained target block is serialized, and the serialization result is split to obtain N data blocks;
  • N is a positive integer greater than 1;
  • K-X data blocks are obtained from the split N data blocks; from
  • the encoding matrix obtains the matrix elements corresponding to the X check blocks and the K-X data blocks, and determines a data recovery reference based on the obtained matrix elements corresponding to the X check blocks and the K-X data blocks.
  • Matrix determine the inverse matrix of the data recovery reference matrix, and recover the target block based on the inverse matrix of the data recovery reference matrix, the X check blocks and the K-X data blocks.
  • the processing unit 1001 is further configured to: detect the target block recovered based on the inverse matrix of the data recovery reference matrix, the X check blocks and the K-X data blocks, and the target block recovered from Whether the target blocks obtained by the consensus nodes in the consensus network are consistent; if they are consistent, it is determined that the target block is restored successfully.
  • the number of check blocks of the target block is K, and K is a positive integer greater than 1; the processing unit 1001 is also used to: obtain the service in the witness network through the transceiver unit 1002
  • the node obtains the block header of the reference block; the reference block is the next block of the target block on the blockchain, and the block header of the reference block includes K corresponding to the target block.
  • the root of the Merkle tree constructed from check blocks; the check block obtained in the target block that does not match the root of the Merkle tree included in the block header of the reference block Block discarded. That is to say: the follow-up is based on the encoding matrix and the obtained root of the Merkel tree included in the block header of the reference block.
  • the check block determines the data recovery reference matrix, and recovers the target block based on the data recovery reference matrix and the obtained check block that matches the root of the Merkel tree included in the block header of the reference block.
  • the processing unit 1001 is further configured to: serialize the first block and split the serialization result to obtain N data blocks; the first block is the block Any block on the chain; N is a positive integer greater than 1; the split N data blocks are formed into an N*1 data block matrix; the data block matrix is encoded using the encoding matrix to obtain Coding result; the coding result includes K check blocks and split N data blocks; K is a positive integer greater than 1; all or part of the K check blocks are stored through the storage unit 1003 piece.
  • the consensus network is composed of a network of G consensus nodes, G is a positive integer greater than 1, and K is equal to G; the processing unit 1001 stores the K verification blocks through the storage unit 1003 When all or part of the check blocks are checked, it is specifically used to: determine from the K check blocks the matching check block whose arrangement identifier matches the arrangement identifier of the data processing device (or target consensus node) in the consensus network. check block; store the matching check block through the storage unit 1003.
  • the processing unit 1001 is further configured to: perform hash calculation on each of the K check blocks to obtain K hash values; based on the K hash values Construct a Merkle tree, and add the root of the constructed Merkle tree to the block header of the second block; the second block is the next area of the first block on the blockchain piece.
  • the transceiver unit 1002 is also configured to receive a block synchronization request sent by a target service node, where the block synchronization request carries a synchronization block height and a node identifier of the target service node; the target The business node is any business node in the witness network;
  • the processing unit 1001 is also configured to: determine a matching block that matches the height of the synchronized block from the blockchain, and obtain the block header of the matching block and all the information included in the matching block. Describe the transaction data that the target business node has access rights to; obtain the matching verification block that matches the node identification among the K verification blocks;
  • the sending and receiving unit 1002 is also configured to send the block header of the matching block, the transaction data with access rights, and the matching verification block to the target service node.
  • the data processing device may be a target service node corresponding to the witness network mentioned above, where:
  • the processing unit 1001 is configured to send a block synchronization request to the consensus node in the consensus network through the transceiver unit 1002;
  • the block synchronization request carries the synchronization block height and data processing device (or target business node );
  • the synchronization block height is the block height of the target block that needs to be synchronized, and the target block is a block on the blockchain maintained by the consensus node in the consensus network;
  • the zone The block synchronization request is used to request the consensus node to return relevant data of the target block;
  • the transceiver unit 1002 is also configured to receive relevant data of the target block returned by the consensus node; the relevant data includes the block header of the target block, the data processing included in the target block.
  • the device (or the target business node) has access rights to the transaction data and the matching check blocks that match the node identification among the K check blocks corresponding to the target block; the K check blocks are generated using The encoding matrix is obtained by encoding the target block; K is a positive integer greater than 1;
  • the storage unit 1003 is used to store relevant data of the target block; wherein the stored matching verification block is used by the consensus node in the consensus network to restore the target block.
  • the transceiver unit 1002 is also used to receive the transmission from the target consensus node in the consensus network.
  • a verification block acquisition request regarding the target block is a request sent by the target consensus node to the target block when it determines that it is necessary to restore the target block based on the verification block of the target block.
  • the description is broadcast by the business nodes in the witness network;
  • the processing unit 1001 is also configured to send the matching verification block corresponding to the stored target block to the consensus node through the transceiver unit 1002, so that the target consensus node can perform verification based on the matching verification block.
  • the verification block restores the target block.
  • the processing unit 1001 is further configured to: obtain the block header of a reference block synchronized from a consensus node in the consensus network, where the reference block is the target area on the blockchain.
  • the next block of the block, the block header of the reference block includes the root of the Merkel tree constructed based on the K check blocks corresponding to the target block; if the matching check blocks in the relevant data If the check block matches the root of the Merkle tree included in the block header of the reference block, the matching check block is stored in the storage unit 1003.
  • the consensus node generates the verification block of the block, and when the business node synchronizes the block, the verification block of the block and the relevant block data of the block are synchronized to the business node, and when the consensus node
  • the consensus node When a block needs to be restored, the verification block of the block that needs to be restored is obtained from the business node, and the block can be successfully restored based on the obtained verification block.
  • the consensus network when the consensus network is in an unavailable state and the block recovery cannot be completed based on the block data stored by the business node, the block can also be successfully recovered based on the verification block stored by the business node, and can effectively guarantee Availability of recovered blocks.
  • the data processing device provided by the embodiment of the present application can be implemented in a software manner.
  • the data processing device can be stored in the memory, which can be software in the form of programs, plug-ins, etc., and includes a series of units, including A processing unit, a communication unit and a storage unit; wherein the processing unit, communication unit and storage unit are used to implement the data processing method based on the blockchain network provided by the embodiments of the present application.
  • the data processing device provided by the embodiment of the present application can also be implemented by combining software and hardware.
  • the data processing device provided by the embodiment of the present application can be in the form of a hardware decoding processor.
  • a processor in the form of a hardware decoding processor can adopt one or more Application Specific Integrated Circuits (ASIC, Application Specific Integrated Circuit), DSP, programmable logic device (PLD, Programmable Logic Device), complex programmable logic device (CPLD, Complex Programmable Logic Device), field programmable gate array (FPGA, Field-Programmable Gate Array) or other electronic components.
  • ASIC Application Specific Integrated Circuit
  • DSP digital signal processor
  • PLD programmable logic device
  • CPLD Complex Programmable Logic Device
  • FPGA Field-Programmable Gate Array
  • FIG. 11 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
  • the computer device described in the embodiment of this application includes: a processor 1101, a communication interface 1102, and a memory 1103. Among them, the processor 1101, the communication interface 1102 and the memory 1103 can be connected through a bus or other means. In the embodiment of this application, the connection through a bus is taken as an example.
  • the processor 1101 (or CPU (Central Processing Unit)) is the computing core and control core of the computer device. It can parse various instructions in the computer device and process various data of the computer device, such as: The CPU can be used to parse the power on and off instructions sent by the user to the computer device, and control the computer device to perform power on and off operations; another example: the CPU can transmit various types of interactive data between the internal structures of the computer device, and so on.
  • the communication interface 1102 may optionally include a standard wired interface, a wireless interface (such as Wi-Fi, mobile communication interface etc.), controlled by the processor 1101 for sending and receiving data.
  • Memory 1103 (Memory) is a memory device in a computer device, used to store programs and data.
  • the memory 1103 here may include a built-in memory of the computer device, and of course may also include an extended memory supported by the computer device.
  • the memory 1103 provides storage space, and the storage space stores the operating system of the computer device, which may include but is not limited to: Android system, iOS system, Windows Phone system, etc. This application is not limited to this.
  • the computer device is used in a blockchain network.
  • the blockchain network includes a witness network and a consensus network.
  • the witness network is composed of multiple business nodes
  • the consensus network is composed of multiple business nodes. It is composed of a network of consensus nodes, and a communication connection is established between the witness network and the consensus network.
  • the computer device may be a target consensus node corresponding to the consensus network described above, wherein the processor 1101 performs the following operations by running the executable program code in the memory 1103:
  • the check block of the target block is obtained from the service node in the witness network through the communication interface 1102; based on the encoding matrix and from the Determine the data recovery reference matrix based on the check block obtained by the service node in the witness network; restore and obtain the target block based on the data recovery reference matrix and the check block obtained from the service node in the witness network;
  • the target block is a block on the blockchain maintained by the consensus node in the consensus network;
  • the check block of the target block stored by the business node is the block on which the business node is located. It is obtained when the consensus node in the consensus network synchronizes the relevant block data of the target block;
  • the verification block is obtained by encoding the target block by the consensus node in the consensus network using the encoding matrix. ;
  • the check block is used to restore the target block.
  • the processor 1101 is further configured to: if it is detected that the target block needs to be restored and the proportion of abnormal consensus nodes in the consensus network exceeds a set proportion, and the number of abnormal consensus nodes in the witness network is If the service node does not store all the block data of the target block, it is determined that the target block needs to be restored based on the check block of the target block.
  • the number of check blocks of the target block is K, and K is a positive integer greater than 1; the processor 1101 determines based on the coding matrix and the check blocks obtained from the service nodes in the witness network.
  • Data recovery reference matrix when recovering the target block based on the data recovery reference matrix and the check block obtained from the business node in the witness network, is specifically used for:
  • matrix elements corresponding to the K check blocks are obtained from the encoding matrix; based on the obtained K check blocks
  • the matrix element corresponding to the check block determines the data recovery reference matrix, and determines the inverse matrix of the data recovery reference matrix; the target block is recovered based on the inverse matrix of the data recovery reference matrix and the K check blocks .
  • the target block is obtained from the consensus node in the consensus network;
  • X is a positive integer less than K;
  • the obtained target block is serialized, and the serialization result is split to obtain N data blocks;
  • N is a positive integer greater than 1;
  • K-X data blocks are obtained from the split N data blocks; from
  • the encoding matrix obtains the matrix elements corresponding to the X check blocks and the K-X data blocks, and determines a data recovery reference based on the obtained matrix elements corresponding to the X check blocks and the K-X data blocks.
  • Matrix determine the inverse matrix of the data recovery reference matrix, and recover the target block based on the inverse matrix of the data recovery reference matrix, the X check blocks and the K-X data blocks.
  • the processor 1101 is further configured to: detect the target block recovered based on the inverse matrix of the data recovery reference matrix, the X check blocks and the KX data blocks, and the target block recovered from the Whether the target blocks obtained by the consensus nodes in the consensus network are consistent; if they are consistent, it is determined that the target block is restored successfully.
  • the number of check blocks of the target block is K, and K is a positive integer greater than 1; the processor 1101 is also configured to: obtain the reference area from the service node in the witness network through the communication interface 1102 The block header of the block; the reference block is the next block of the target block on the blockchain, and the block header of the reference block includes K verification blocks corresponding to the target block. The root of the constructed Merkle tree; among the obtained check blocks of the target block, the check blocks that do not match the root of the Merkle tree included in the block header of the reference block are discarded.
  • the subsequent step is to determine the data recovery reference matrix based on the coding matrix and the obtained check block that matches the root of the Merkel tree included in the block header of the reference block, and based on the data recovery reference matrix and The target block is recovered from the obtained check block that matches the root of the Merkle tree included in the block header of the reference block.
  • the processor 1101 is further configured to: serialize the first block and split the serialization result to obtain N data blocks; the first block is on the blockchain any block of ;
  • the encoding result includes K check blocks and N data blocks obtained by splitting; K is a positive integer greater than 1; all or part of the K check blocks are stored in the memory 1103.
  • the consensus network consists of a network of G consensus nodes, G is a positive integer greater than 1, and K is equal to G; the processor 1101 stores all or all of the K check blocks through the memory 1103.
  • a partial check block it is specifically used to: determine from the K check blocks a matching check block whose arrangement identifier matches the arrangement identifier of the computer device (or target consensus node) in the consensus network; by Memory 1103 stores the matching check blocks.
  • the processor 1101 is further configured to: perform hash calculation on each of the K check blocks to obtain K hash values; and construct a database based on the K hash values. Kerr tree, and add the root of the constructed Merkel tree to the block header of the second block; the second block is the next block of the first block on the blockchain.
  • the processor 1101 is further configured to: receive a block synchronization request sent by the target service node through the communication interface 1102, where the block synchronization request carries the synchronization block height and the node identification of the target service node;
  • the target business node is any business node in the witness network; determine the matching block that matches the synchronization block height from the blockchain, and obtain the block header and the block header of the matching block.
  • the matching block includes the transaction data that the target business node has access rights to; obtains the matching verification block that matches the node identification among the K verification blocks; and sends the matching block through the communication interface 1102
  • the block header, the transaction data with access rights and the matching verification block are sent to the target business node.
  • the computer device may be a target business node corresponding to the aforementioned witness network, wherein the processor 1101 performs the following operations by running the executable program code in the memory 1103:
  • the block synchronization request carries the synchronization block height and the node identification of the computer device (or target business node);
  • the synchronization block height is the block height of the target block that needs to be synchronized, and the target block is a block on the blockchain maintained by the consensus node in the consensus network;
  • the block synchronization request is used to request the consensus node to return Relevant data of the target block;
  • the relevant data includes the block header of the target block, the computer equipment (or target business) included in the target block Node) has access rights to the transaction data and the matching check block that matches the node identification among the K check blocks corresponding to the target block;
  • the K check blocks are the target block using a coding matrix. Obtained by encoding the block; K is a positive integer greater than 1;
  • the relevant data of the target block is stored in the memory 1103; wherein the stored matching verification block is used by the consensus node in the consensus network to restore the target block.
  • the processor 1101 is further configured to: receive a verification block acquisition request regarding the target block sent by the target consensus node in the consensus network through the communication interface 1102; the verification block acquisition request is The target consensus node broadcasts to the business nodes in the witness network when it determines that the target block needs to be restored based on the check block of the target block;
  • the matching verification block corresponding to the stored target block is sent to the consensus node through the communication interface 1102, so that the target consensus node restores the target block based on the matching verification block.
  • the processor 1101 is further configured to: obtain the block header of the reference block synchronized from the consensus node in the consensus network, where the reference block is the block header of the target block on the blockchain. For the next block, the block header of the reference block includes the root of the Merkel tree constructed based on the K check blocks corresponding to the target block; if the matching check block in the relevant data , matches the root of the Merkle tree included in the block header of the reference block, then the matching check block is stored in the memory 1103.
  • the processor 1101, communication interface 1102 and memory 1103 described in the embodiments of this application can implement the data processing method based on the blockchain network in the above method embodiments.
  • the specific implementation process can be referred to in the above method embodiments. The relevant descriptions will not be repeated here.
  • the consensus node generates the verification block of the block, and when the business node synchronizes the block, the verification block of the block and the relevant block data of the block are synchronized to the business node, and when the consensus node
  • the consensus node When a block needs to be restored, the verification block of the block that needs to be restored is obtained from the business node, and the block can be successfully restored based on the obtained verification block.
  • the consensus network when the consensus network is in an unavailable state and the block recovery cannot be completed based on the block data stored by the business node, the block can also be successfully recovered based on the verification block stored by the business node, and can effectively guarantee Availability of recovered blocks.
  • Embodiments of the present application also provide a computer-readable storage medium.
  • a computer program is stored in the computer-readable storage medium.
  • the computer can implement the block-based method as described in the embodiments of the present application. Data processing method of chain network. The specific implementation method can be referred to the previous description and will not be repeated here.
  • Embodiments of the present application also provide a computer program product.
  • the computer program product includes a computer program or computer instructions.
  • the method described in the embodiments of the present application is implemented based on blocks. Data processing on the chain network.
  • the specific implementation method can be referred to the previous description and will not be repeated here.
  • the program can be stored in a computer-readable storage medium.
  • the storage medium can include: Flash disk, Read-Only Memory (ROM), Random Access Memory (RAM), magnetic disk or optical disk, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Databases & Information Systems (AREA)
  • Business, Economics & Management (AREA)
  • Computer Security & Cryptography (AREA)
  • Accounting & Taxation (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请实施例提供了基于区块链网络的数据处理方法及相关产品,其中方法包括:在确定需要基于目标区块的校验块来恢复目标区块时,从见证网络中的业务节点获取目标区块的校验块;业务节点存储的目标区块的校验块,是业务节点在从共识网络中的共识节点同步目标区块的相关区块数据时获取得到,该校验块用于恢复目标区块;基于编码矩阵以及从见证网络中的业务节点获取到的校验块确定数据恢复参考矩阵;基于数据恢复参考矩阵以及从见证网络中的业务节点获取到的校验块恢复得到目标区块。通过本申请实施例可以成功恢复出区块,并且可以有效保证恢复出的区块的可用性。

Description

基于区块链网络的数据处理方法及相关产品 技术领域
本申请涉及区块链技术领域,尤其涉及基于区块链网络的数据处理方法、数据处理装置、计算机设备、计算机可读存储介质以及计算机程序产品。
背景技术
随着科技时代的到来和移动互联网的发展,网络变革的步伐也愈来愈快,实现同一领域或多个领域的信息融合,为客户提供全方位信息化方案的过程亦面临着体系结构的改进、支撑重心转移等新的挑战。因此,区块链技术作为分布式账本的一种特定实现,凭借其存储和管理数据的天然优势,逐渐成为各个领域存储数据和交易数据的首选方式。
区块链是区块链技术的基础,区块链本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。区块链通常是由区块链网络中的共识节点维护,但可能会出现由于诸如存储空间(如硬盘)损坏等因素,导致共识节点维护的区块链的区块数据丢失的情况,此时共识节点则通常需要进行区块数据的恢复,以保证所维护的区块链的完整性,而如何完成区块数据的恢复是目前的研究热点。
发明内容
本申请实施例提供了基于区块链网络的数据处理方法及相关产品,可以成功恢复出区块,并且可以有效保证恢复出的区块的可用性。
一方面,本申请实施例提供了一种基于区块链网络的数据处理方法,所述区块链网络包括见证网络和共识网络,所述见证网络由多个业务节点组网构成,所述共识网络由多个共识节点组网构成,所述见证网络和所述共识网络建立有通信连接;所述方法包括:
在确定需要基于目标区块的校验块来恢复所述目标区块时,从所述见证网络中的业务节点获取所述目标区块的校验块;基于编码矩阵以及从所述见证网络中的业务节点获取到的校验块确定数据恢复参考矩阵;基于所述数据恢复参考矩阵以及从所述见证网络中的业务节点获取到的校验块恢复得到所述目标区块;其中,所述目标区块为所述共识网络中的共识节点维护的区块链上的区块;所述业务节点存储的所述目标区块的校验块,是所述业务节点在从所述共识网络中的共识节点同步所述目标区块的相关区块数据时获取得到;所述校验块是所述共识网络中的共识节点利用所述编码矩阵对所述目标区块进行编码得到;所述校验块用于恢复所述目标区块。
一方面,本申请实施例提供了另一种基于区块链网络的数据处理方法,所述区块链网络包括见证网络和共识网络,所述见证网络由多个业务节点组网构成,所述共识网络由多个共识节点组网构成,所述见证网络和所述共识网络建立有通信连接;所述方法包括:
向所述共识网络中的共识节点发送区块同步请求;所述区块同步请求携带同步区块高度以及目标业务节点的节点标识;所述同步区块高度为需要同步的目标区块的区块高度,所述目标区块为所述共识网络中的共识节点维护的区块链上的区块;所述区块同步请求用 于请求所述共识节点返回所述目标区块的相关数据;接收所述共识节点返回的所述目标区块的相关数据;所述相关数据包括所述目标区块的区块头、所述目标区块包括的所述目标业务节点具有访问权限的交易数据以及所述目标区块对应的K个校验块中与所述节点标识相匹配的匹配校验块;所述K个校验块是利用编码矩阵对所述目标区块进行编码得到;K为大于1的正整数;存储所述目标区块的相关数据;其中,存储的所述匹配校验块用于供所述共识网络中的共识节点恢复所述目标区块时使用。
一方面,本申请实施例提供了一种数据处理装置,所述数据处理装置应用于区块链网络中,所述区块链网络包括见证网络和共识网络,所述见证网络由多个业务节点组网构成,所述共识网络由多个共识节点组网构成,所述见证网络和所述共识网络建立有通信连接;所述装置包括:
处理单元,用于在确定需要基于目标区块的校验块来恢复所述目标区块时,通过收发单元从所述见证网络中的业务节点获取所述目标区块的校验块;
所述处理单元,还用于基于编码矩阵以及从所述见证网络中的业务节点获取到的校验块确定数据恢复参考矩阵;
所述处理单元,还用于基于所述数据恢复参考矩阵以及从所述见证网络中的业务节点获取到的校验块恢复得到所述目标区块;
其中,所述目标区块为所述共识网络中的共识节点维护的区块链上的区块;所述业务节点存储的所述目标区块的校验块,是所述业务节点在从所述共识网络中的共识节点同步所述目标区块的相关区块数据时获取得到;所述校验块是所述共识网络中的共识节点利用所述编码矩阵对所述目标区块进行编码得到;所述校验块用于恢复所述目标区块。
一方面,本申请实施例提供了另一种数据处理装置,所述数据处理装置应用于区块链网络中,所述区块链网络包括见证网络和共识网络,所述见证网络由多个业务节点组网构成,所述共识网络由多个共识节点组网构成,所述见证网络和所述共识网络建立有通信连接;所述装置包括:
处理单元,用于通过收发单元向所述共识网络中的共识节点发送区块同步请求;所述区块同步请求携带同步区块高度以及目标业务节点的节点标识;所述同步区块高度为需要同步的目标区块的区块高度,所述目标区块为所述共识网络中的共识节点维护的区块链上的区块;所述区块同步请求用于请求所述共识节点返回所述目标区块的相关数据;
所述收发单元,还用于接收所述共识节点返回的所述目标区块的相关数据;所述相关数据包括所述目标区块的区块头、所述目标区块包括的所述目标业务节点具有访问权限的交易数据以及所述目标区块对应的K个校验块中与所述节点标识相匹配的匹配校验块;所述K个校验块是利用编码矩阵对所述目标区块进行编码得到;K为大于1的正整数;
存储单元,用于存储所述目标区块的相关数据;其中,存储的所述匹配校验块用于供所述共识网络中的共识节点恢复所述目标区块时使用。
一方面,本申请实施例提供了一种计算机设备,包括:处理器、通信接口和存储器,所述处理器、所述通信接口和所述存储器相互连接,其中,所述存储器存储有可执行程序代码,所述处理器用于调用所述可执行程序代码,实现本申请实施例提供的基于区块链网络的数据处理方法。
相应地,本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机实现本申请实施例提供的基于区块链 网络的数据处理方法。
相应地,本申请实施例还提供了一种计算机程序产品,所述计算机程序产品包括计算机程序或计算机指令,所述计算机程序或计算机指令存被处理器执行时实现本申请实施例提供的基于区块链网络的数据处理方法。
本申请实施例中,共识节点生成区块的校验块,并在业务节点同步区块时,将区块的校验块与区块的相关区块数据一起同步给业务节点,而在共识节点需要恢复区块时,从业务节点获取需要恢复的区块的校验块,即可基于获取到的校验块成功恢复出区块。采用此方式,可以在共识网络处于不可用状态,且基于业务节点存储的区块数据无法完成区块的恢复时,也能够基于业务节点存储的校验块成功恢复出区块,并且可以有效保证恢复出的区块的可用性。
附图简要说明
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1a是本申请实施例提供的一种区块链的结构示意图;
图1b是本申请实施例提供的一种数据共享***的架构示意图;
图2a是本申请实施例提供的一种分层区块链网络的架构示意图;
图2b示出了图2a所示分层区块链网络中不同业务的交易数据之间的隔离;
图3a示出了本申请实施例涉及的校验块分发过程;
图3b示出了本申请实施例涉及的区块恢复过程;
图4示出了本申请实施例涉及的校验块生成及存储阶段的流程;
图5示出了本申请实施例涉及的校验块生成方式;
图6示出了本申请实施例涉及的区块数据及校验块同步阶段的流程;
图7示出了本申请实施例涉及的区块恢复阶段的流程;
图8是本申请实施例提供的一种数据恢复参考矩阵的示意图;
图9是本申请实施例提供的一种数据矩阵的示意图;
图10是本申请实施例提供的一种数据处理装置的结构示意图;
图11是本申请实施例提供的一种计算机设备的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
为更好的理解本申请实施例,下面先对本申请实施例所涉及的一些术语以及区块链技术进行介绍。
共识节点:区块链网络中的共识节点负责产生区块,共识节点除了负责打包一批交易、 执行交易以外,还负责与其余共识节点达成共识以更新链状态,共识节点拥有全量的区块链数据。
清分:上级节点根据下级节点的权限,向下级节点同步交易。
业务节点:业务节点是区块链网络中的一种轻量级节点,业务节点负责处理业务上的请求,并将业务请求透传给共识节点;业务节点同步所有的区块头,且只同步该节点可见(即具有访问权限)的交易数据;业务节点向共识节点或者业务节点的上级节点发起同步请求,共识节点或上级节点将区块头以及业务节点可见的交易数据清分给业务节点。
梅克尔(Merkle)树、Merkle树根:Merkle树是一种典型的二叉树结构,由一个根结点(即Merkle树根),一组中间节点和一组叶子节点构成。最下层的叶子节点存储数据或其哈希值,其他节点存储其两个子节点内容的哈希值。
Pbft共识算法(即基于实用拜占庭容错算法的共识算法):是一种基于消息传递的一致性算法,算法经过三个阶段达成一致性。当存在f个拜占庭错误节点时,若节点总数大于或等于3f+1,所有节点依然能够达成最终一致(即能够完成共识);反之,若节点总数小于3f+1,则所有节点不能够达成最终一致(即不能够完成共识)。
纠删码:纠删码技术主要是通过纠删码算法将原始的数据进行编码得到冗余,并将数据和冗余一并存储起来,以达到容错的目的。其基本思想是将n块原始的数据元素通过一定的计算,得到m块冗余元素(校验块)。对于这n+m块的元素,当其中任意的m块元素出错(包括原始数据和冗余数据)时,均可以通过对应的重构算法恢复出原来的n块数据。
本申请实施例涉及区块链(Blockchain)技术,区块链是区块链技术的基础,所谓区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式。区块链本质上是一个去中心化的数据库,是一串使用密码学方法相关联产生的数据块,每一个数据块中包含了一批次网络交易的信息,用于验证其信息的有效性(防伪)和生成下一个区块。一种区块链的结构示意图可参见图1a,如图1a所示,区块链101由多个区块组成,区块链的第一个区块称为创世区块(可简称为创世块),创世块中包括区块头和区块主体,区块头中存储有输入信息特征值、版本号、时间戳和难度值,区块主体中存储有输入信息(包括交易数据);创世块的下一区块以创世块为父区块,下一区块中同样包括区块头和区块主体,区块头中存储有当前区块的输入信息特征值、父区块的区块头特征值、版本号、时间戳和难度值,并以此类推,使得区块链中每个区块中存储的区块数据均与父区块中存储的区块数据存在关联,保证了区块中输入信息的安全性。
区块链可由区块链网络所包含的区块链节点进行维护;其中,区块链网络可以理解为一个数据共享***,是指用于进行区块链节点与区块链节点之间数据共享的***,该数据共享***的一种示例性结构可参见图1b;如图1b所示,数据共享***中可包括多个区块链节点102,各个区块链节点102可以为接入至该区块链网络中的服务器,也可以为接入至该区块链网络中的终端设备(如客户端),这里对区块链节点102的具体形式不做限定。对于区块链网络中的每个区块链节点102,均具有与其对应的节点标识,而且区块链网络中的每个区块链节点102均可以存储有区块链网络中其它区块链节点102的节点标识,以便后续根据其它区块链节点102的节点标识,将生成的区块广播至数据共享***中的其它区块链节点102。每个区块链节点102中可维护一个节点标识列表,将节点名称和节点标识对应存储至节点标识列表中;其中,节点标识列表可参见表1:
表1
如表1所示,节点标识可为IP(Internet Protocol,网络之间互联的协议)地址以及其它任一种能够用于标识该节点的信息;例如,节点标识还可以是二进制序列码(如110001110),表1中仅以IP地址为例进行说明。当区块链网络中产生待验证区块时,区块链网络中运行共识机制的区块链节点(或称为共识节点)对该待验证区块进行共识,并在共识成功后通过节点标识列表中的节点标识,将该待验证区块同步至区块链网络中的各个区块链节点,实现在区块链网络中对数据的分布式存储。
图1b所示的区块链网络为单层区块链网络,即节点对等,处于同一个网络中。但当区块链网络被用于诸如政府或者商业机构的一些应用场景中时,并非所有的区块链参与节点都有足够的资源和必要性成为参与区块链共识的节点;而出于对数据的安全性考虑,在区块链体系中涉及保密数据时,也不宜采用普遍的数据对等式的区块链部署方式。可见,单层(即节点对等)的区块链网络并不适用于上述多种应用场景。
为解决上述问题,本申请实施例提供了一种分层区块链网络,如图2a所示,区块链网络被分成见证网络和共识网络两层,见证网络由多个业务节点组网构成,共识网络由多个共识节点组网构成,见证网络和共识网络之间建立有通信连接。其中,见证网络中的业务节点为轻量级节点,共识网络中的共识节点为全量级节点。共识节点在共识网络中参与出块(即产生区块)以及共识等,且各个共识节点拥有全量的区块链数据,或者说存储有区块链上的所有区块的区块数据;业务节点在见证网络中执行业务逻辑、向共识网络提交业务操作、从共识节点同步区块数据(同步所有的区块头,且只同步该节点可见(或者说具有访问权限)的交易数据)等。见证网络和共识网络处在不同网络环境下,见证网络通常处于公有网络中,业务节点的加入/退出相对自由;而共识网络通常部署在一个相对安全且封闭的私有网络中,共识节点的加入/退出需要经过共识委员会(或者说共识网络中的所有共识节点)的共识。
图2a所示的分层区块链网络为共识节点+业务节点的体系,可以实现不同业务的交易数据之间的隔离,如图2b所示;另外,除了在共识网络内存储全量的交易数据外,共识节点还会根据业务节点的权限将业务相关的交易数据清分到业务节点。该分层区块链的设计满足了业界对交易保密性的要求,也在一定程度上增强了区块链数据的可用性,即使存在共识网络数据不可信/不可用的情况,业务节点上存储的历史交易数据依然是可以被查询的。
通过将区块链网络划分成见证网络和共识网络,可以将区块链网络中的各节点按照功能的不同进行区分(分成共识节点和业务节点),一方面可以实现分层区块链网络,并且只需将区块链网络中的部分节点作为共识节点,这样有利于提高共识效率;另一方面可以使得处于不同网络的节点存储不同的数据,实现数据不对等的区块链部署方式,这样可以提高数据的安全性和保密性。基于上述优势,分层区块链网络可以适用于单层区块链网络不适用的应用场景。
对于图2a所示的分层区块链网络,当共识节点A(共识网络中的任意一个共识节点) 由于诸如存储空间(如硬盘)损坏等因素导致区块B(区块链上的任意一个区块)的区块数据(如交易数据)丢失,而需要恢复区块B时,或者当节点C新加入共识网络成为共识节点,而需要同步所有的区块数据(以下以同步区块B为例进行说明,其余区块类似)时,如果此时共识网络中的共识节点能够达成一致性共识,则共识节点A或者共识节点C可以直接从共识网络中的其他共识节点同步能够通过共识的区块B。
在一个有3f+1个共识节点的共识网络中,f为大于或等于1的正整数,以f=1为例,若有2个及以上共识节点由于诸如相关数据丢失或者掉线等原因而无法参与(或者说完成)共识,则由于能参与共识的节点所占的比例不能超过设定比例(如1/2),会导致无法达成一致性共识,这时共识网络便处于不可用的状态。如果共识网络中的共识节点不能够达成一致性共识,则其他共识节点存储的区块B的正确性(或者说可用性)无法确定,无法直接从其他共识节点同步区块B。由于见证网络中的业务节点可能存储有区块B的区块数据,共识节点A或者共识节点C此时可以尝试从见证网络中的业务节点获取区块B的所有区块数据,如果从见证网络中的业务节点能够获取到区块B的所有区块数据,则可以基于获取到的区块B的所有区块数据直接恢复出区块B。而如果由于诸如见证网络中的业务节点未能够同步得到区块B的所有区块数据(例如区块B中的交易数据对所有的业务节点均不可见,则业务节点只能同步得到区块B的区块头)、或者原本同步有区块B的区块数据的业务节点退出了区块链网络而导致其余业务节点未能包括区块B的所有区块数据等因素,导致共识节点A或者共识节点C从见证网络中的业务节点不能够获取到区块B的所有区块数据,此时共识节点A或者共识节点C则无法得到区块B。
基于此,本申请实施例提供了一种区块恢复方案,以在共识网络处于不可用状态(即共识网络中的共识节点不能够达成一致性共识),且基于见证网络中的业务节点存储的区块数据无法完成区块的恢复时,也能够成功恢复出区块,并且可以有效保证恢复出的区块的可用性(或者说准确性)。
本申请实施例提供的区块恢复方案主要包括如图3a所示的校验块分发过程以及如图3b所示的通过校验块来恢复区块的过程。共识节点生成区块链上每一个区块的校验块,业务节点在从共识节点正常同步区块数据时,除了同步一个区块中业务节点相关交易数据以及区块头之外,还需要额外同步该区块的校验块。当共识节点需要通过校验块来恢复区块时,共识节点向业务节点请求校验块,并在集到足够多数量的校验块后即可基于获取到的校验块成功恢复出区块的区块数据。
结合上述恢复区块B的例子对本申请实施例提供的区块恢复方案进行举例说明,主要处理流程如下:共识网络中的每一个共识节点在将区块B上链之后,利用编码矩阵对区块B进行编码,得到区块B的K个校验块,K为大于1的正整数,该K个校验块用于恢复区块B;然后存储K个校验块中的全部或者部分校验块;在接收到见证网络中的业务节点发送的关于区块B的区块同步请求时,获取区块B的区块头以及区块B包括的业务节点具有访问权限的交易数据,并获取区块B的K个校验块中与业务节点的节点标识相匹配的匹配校验块;然后将区块B的区块头、区块B包括的业务节点具有访问权限的交易数据、以及该匹配校验块发送给业务节点,业务节点存储接收到的数据。当上述共识节点A需要恢复区块B或者上述共识节点C需要同步区块B,且共识网络处于不可用状态,以及基于见证网络中的业务节点存储的区块数据无法完成区块B的恢复时,共识节点A或者共识节点C可以从见证网络中的业务节点获取区块B的各个校验块,然后基于编码矩阵以及从见 证网络中的业务节点获取到的区块B的各个校验块确定数据恢复参考矩阵;最后基于该数据恢复参考矩阵以及获取到的区块B的各个校验块恢复,即可成功恢复得到区块B。
以上对本申请实施例提供的区块恢复方案进行了简要介绍,下面对该区块恢复方案(即以下所述的数据处理方法)进行详细介绍。
本申请实施例提供的数据处理方法基于图2a所示的分层区块链网络实现,该数据处理方法包括校验块生成及存储阶段、区块数据及校验块同步阶段以及区块恢复阶段三个阶段,下面分别对各个阶段的处理流程进行详细说明。
一、校验块生成及存储阶段,由共识网络中的目标共识节点(为共识网络中的任意一个共识节点)执行实现。请参阅图4,图4示出了本申请实施例提供的数据处理方法所包括的校验块生成及存储阶段的处理流程,该校验块生成及存储阶段包括但不限于如下步骤:
S401、将第一区块进行序列化处理,并对序列化结果进行拆分得到N个数据块。
本申请实施例中,第一区块为区块链(即共识网络中的共识节点所维护的区块链)上的任意一个区块,N为大于1的正整数。序列化处理是指将数据分解成字节流。在将第一区块序列化处理完成后,对序列化处理得到的字节流进行拆分得到D1、D2、......、DN共计N个数据块。其中,可以按照等数据量对序列化处理得到的字节流进行拆分得到N个数据块,当然也可以按照非等数据量进行拆分,本申请实施例对拆分方式不作限定。
需要说明的是,数据块Di(i为1-N中的任意一个)的下标可以表示相应数据块在序列化处理结果中的排列顺序,例如标识为D1的数据块为序列化处理结果中排在第一位的数据块;当然数据块Di的下标也可以与相应数据块在序列化处理结果中的排列顺序不相关,例如标识为D3的数据块可以为序列化处理结果中排在第一位的数据块。
S402、将拆分得到的N个数据块组成一个N*1的数据块矩阵。该数据块矩阵如图5中的504所示。
S403、利用编码矩阵对数据块矩阵进行编码,得到编码结果;该编码结果包括K个校验块以及拆分得到的N个数据块;K为大于1的正整数。
本申请实施例中,编码矩阵可以是基于范德蒙矩阵构建的,该编码矩阵的任意W*H子矩阵均可逆。该编码矩阵可以是由一个N*N的单位矩阵以及一个K*N的编码参数矩阵拼接而成。该编码矩阵的形态可以是如图5中的501所示,包括502所示的N*N单位矩阵,以及503所示的K*N编码参数矩阵,503所示的M11、M12、......、MKN总计K*N个编码参数的具体取值由目标共识节点自行定义,只要定义后能够保证编码矩阵的任意W*H子矩阵均可逆即可。其中,W为大于或等于1且小于或等于K+N的正整数,H为大于或等于1且小于或等于N的正整数,W与H可以相等,也可以不相等;K可以与N相等,也可以与N不相等。
在一实施例中,利用编码矩阵对数据块矩阵进行编码,可以是将编码矩阵和数据块矩阵进行矩阵相乘。如图5所示,将编码矩阵501和数据块矩阵504进行矩阵相乘后,得到505所示的编码结果,该编码结果为一个(N+K)*1的矩阵,矩阵的前N个元素为第一区块的N个数据块D1、D2、......、DN,矩阵的后K个元素为针对该N个数据块生成的校验块C1、C2、......、CK,每一个校验块Ci(i为1-k中的任意一个)均是基于上述编码参数矩阵的一行元素以及该N个数据块生成的,例如校验块C1是基于编码参数矩阵的第一行元素(M11、M12、......、M1N)以及数据块矩阵(D1、D2、......、DN)得到,即校验块C1与编码参数矩阵的第一行元素(M11、M12、......、M1N)具有对应关系。其余情况类似,在 此不再赘述。
S404、存储K个校验块中的全部或者部分校验块。
本申请实施例中,目标共识节点可以存储第一区块的全部K个校验块。而当K的取值比较大(如100000)时,如果存储第一区块的全部K个校验块,则需要较大的存储空间;另外,共识网络中的每一个共识节点均会采用如上方式针对第一区块生成K个校验块,如果每个共识节点均存储第一区块的全部K个校验块,则会造成数据冗余。为节省存储空间以及降低数据冗余,可以将第一区块的K个校验块分散存储在共识网络中的多个共识节点中,此时目标共识节点只需存储第一区块的K个校验块中的部分校验块即可。
在一实施方式中,如果共识网络由G(G为大于1的正整数)个共识节点组网构成,则可以将G作为K的取值,即K与G相等。目标共识节点可以从第一区块的K个校验块中确定出排列标识与目标共识节点在共识网络中的排列标识相匹配的校验块,并只存储该相匹配的校验块。例如,校验块Ci的下标为其排列标识,用于指示校验块在K个校验块中的排列顺序,共识网络中的共识节点也存在用于指示其排列顺序的排列标识,假设目标共识节点的排列标识指示其在共识网络中的排列顺序为第2,则目标共识节点可以将校验块C2作为相匹配的校验块,并只存储校验块C2。采用此方式,共识网络中的每一个共识节点均会存储第一区块的K个校验块中的一个校验块,且不同共识节点针对第一区块所存储的校验块不同。
在一实施方式中,K与G相等,且N与G也相等,即K、N和G三者相等。另外,W与H也相等。
需要说明的是,步骤S401-步骤S404可以是目标共识节点在将第一区块上链(或者存储到区块链上)之后执行的。
在一实施例中,在确定出第一区块的K个校验块之后,可以对该K个校验块中的每一个校验块进行哈希计算,得到K个哈希值;然后基于计算得到的K个哈希值构建梅克尔(Merkle)树,并将构建的梅克尔树的树根(Merkle树根)加入第二区块的区块头中;第二区块为区块链上第一区块的下一个区块,即区块高度比第一区块大1的区块。需要说明的是,可以是在得到第二区块之后,将第二区块上链之前,将该Merkle树根加入第二区块的区块头中,此时上述步骤可以由目标共识节点执行实现。也可以是在生成第二区块的过程中,将该Merkle树根加入第二区块的区块头中,此时该Merkle树根还可以参与第二区块的区块头哈希值的计算,此时上述步骤是由第二区块的出块节点(可以是目标共识节点,也可以是共识网络中的其他共识节点)执行实现。
需要说明的是,共识网络中的每一个共识节点都会针对区块链上的每一个区块执行步骤S401-步骤S404所示的方式,以完成每一个区块的校验块的生成及存储,具体实现方式请参考上述描述,此处不再赘述。另外,对于同一区块,不同共识节点所使用的编码矩阵相同;而对于不同区块所使用的编码矩阵可以相同,也可以不同。
二、区块数据及校验块同步阶段,由见证网络中的目标业务节点(为见证网络中的任意一个业务节点)以及共识网络中的目标共识节点联合执行实现。请参阅图6,图6示出了本申请实施例提供的数据处理方法所包括的区块数据及校验块同步阶段的处理流程,该区块数据及校验块同步阶段包括但不限于如下步骤:
S601、目标业务节点向共识网络中的目标共识节点发送区块同步请求,区块同步请求携带同步区块高度以及目标业务节点的节点标识。
本申请实施例中,目标共识节点可以是共识网络中的任意一个共识节点,也可以是共识网络中与目标业务节点最近的共识节点,最近可以是指距离最短,也可以是指通信耗时最短;目标共识节点还可以是共识网络中目标业务节点具有访问权限的共识节点。该同步区块高度为需要同步的目标区块的区块高度,目标区块为共识网络中的共识节点维护的区块链上的区块;该区块同步请求用于请求目标共识节点返回目标区块的相关数据。
S602、目标共识节点响应区块同步请求,从区块链上确定与同步区块高度相匹配的匹配区块。
本申请实施例中,目标共识节点可以从区块链上查询区块高度为该同步区块高度的区块,并将区块高度为该同步区块高度的区块确定为匹配区块。该匹配区块即为上述目标业务节点需要同步的目标区块。
S603、目标共识节点获取匹配区块的区块头以及匹配区块包括的目标业务节点具有访问权限的交易数据。
本申请实施例中,目标共识节点获取该匹配区块的区块头,并检测匹配区块的区块体包括的交易数据中是否存在目标业务节点具有访问权限的交易数据,若存在,则从匹配区块的区块体中获取目标业务节点具有访问权限的交易数据,反之若不存在,则不获取交易数据。
S604、目标共识节点获取匹配区块对应的K个校验块中与目标业务节点的节点标识相匹配的匹配校验块。
本申请实施例中,该匹配区块对应的K个校验块是在上述校验块生成及存储阶段,生成并存储在共识网络中的共识节点中。目标共识节点可以基于目标业务节点的节点标识确定一个数值V,然后将匹配区块对应的K个校验块C1、C2、......、CK中下标值与该数值V相同的校验块确定为该匹配校验块。如果目标共识节点自身存储有该匹配校验块,则直接从自身存储空间中获取该匹配校验块;反之,如果目标共识节点自身未存储该匹配校验块,则从共识网络中的其他共识节点处获取该匹配校验块。
在一实施例中,数值V的计算方式如下式所示:
V=Hash(id)mod K
其中,id表示目标业务节点的节点标识,Hash表示哈希运算,mod表示取模运算;上式是指对节点标识id求哈希值之后与数值K相除求余即可得到数值V。
采用上述方式,对于见证网络中的不同业务节点同步该目标区块(即匹配区块)的区块数据时,可以确定出目标区块的不同校验块。这样可以将目标区块的K个校验块(全部或者部分)分散存储到见证网络中的多个业务节点中,这样在后续需要基于校验块来恢复目标区块时,有效保证能够从见证网络的业务节点中获取到足够数量的目标区块的校验块,从而保证目标区块的恢复成功率。
S605、目标共识节点将匹配区块的区块头、匹配区块包括的目标业务节点具有访问权限的交易数据以及匹配校验块发送给目标业务节点。
S606、目标业务节点存储匹配区块(即目标区块)的区块头、匹配区块包括的目标业务节点具有访问权限的交易数据以及匹配校验块。
在一实施例中,在存储该匹配校验块之前,先获取从共识网络中的共识节点同步的参考区块的区块头,参考区块为区块链上目标区块(即匹配区块)的下一个区块,即区块高度比目标区块大1的区块;参考区块的区块头包括基于目标区块对应的K个校验块构建的 梅克尔树的树根,该树根加入参考区块的区块头的方式可参考前文相关描述,此处不再赘述。然后检测该匹配校验块与参考区块包括的梅克尔树的树根是否相匹配,若相匹配则存储该匹配校验块,这样可以保证存储的校验块的准确性。存储的匹配校验块用于供共识网络中的共识节点恢复目标区块时使用。
在一实施方式中,目标共识节点还可以获取匹配校验块的Merkle路径,即基于目标区块对应的K个校验块构建的梅克尔树中从树根节点到匹配校验块对应的节点的路径;并将匹配校验块的Merkle路径发送给目标业务节点。此时,目标业务节点可以检测匹配校验块以及匹配校验块的Merkle路径,是否与参考区块包括的梅克尔树的树根相匹配,若相匹配,则存储该匹配校验块以及匹配校验块的Merkle路径。
另外,需要说明的是,见证网络中的多个(甚至可以说是每一个)业务节点都会基于上述方式针对区块链上的每一个区块进行相关数据的同步,如果业务节点对某个区块中的交易数据不具有访问权限,则只同步区块头以及该某个区块的K个校验块中与业务节点标识相匹配的校验块;如果业务节点对某个区块中的交易数据具有访问权限,则同步区块头、具有访问权限的交易数据以及该某个区块的K个校验块中与业务节点标识相匹配的校验块。基于此,可以将区块链上的各个区块的区块数据(全部或者部分)以及各个区块的K个校验块(全部或者部分)分散存储到见证网络中的多个业务节点中。这样在后续需要基于校验块来进行区块恢复时,有效保证能够从见证网络的业务节点中获取到足够数量的可用校验块,从而保证区块恢复成功率。
三、区块恢复阶段,由共识网络中的目标共识节点以及见证网络中的业务节点联合执行实现,此时的目标共识节点可以是共识网络中由于诸如存储空间(如硬盘)损坏等因素导致区块数据丢失,而需要恢复区块的共识节点;也可以是新加入共识网络成为共识节点,而需要同步所有区块数据的节点。请参阅图7,图7示出了本申请实施例提供的数据处理方法所包括的区块恢复阶段的处理流程,该区块恢复阶段包括但不限于如下步骤:
S701、在确定需要基于目标区块的校验块来恢复目标区块时,从见证网络中的业务节点获取目标区块的校验块。
本申请实施例中,目标区块为需要恢复的区块,可以是区块链上的任意一个区块。若检测到目标共识节点需要恢复目标区块,且共识网络中存在异常的共识节点所占的比例超过设定比例,以及见证网络中的业务节点未存储目标区块的全部区块数据,则确定需要基于目标区块的校验块来恢复目标区块。其中,存在异常的共识节点是指由于诸如相关数据丢失或者掉线等原因而无法参与(或者说完成)共识的共识节点,设定比例例如可以是1/2或者1/3等等,设定比例的取值可以根据共识规则确定。当无法参与共识的共识节点超过设定比例,则表明共识网络中的共识节点无法达成一致性共识,这时共识网络处于不可用的状态。此时其他共识节点存储的目标区块的正确性(或者说可用性)无法确定,无法直接从其他共识节点同步目标区块。与此同时,如果不能从见证网络中的业务节点获取到目标区块的全部区块数据,则只能采用基于目标区块的校验块来恢复目标区块的方式。
在确定需要基于目标区块的校验块来恢复目标区块时,目标共识节点从见证网络中的业务节点获取目标区块的校验块,具体方式可以是:目标共识节点向见证网络中的业务节点广播关于目标区块的校验块获取请求,该校验块获取请求可以携带目标区块的区块高度。见证网络的业务节点接收到该校验块获取请求之后,查询是否存储有目标区块的校验块,若存储有目标区块的校验块,则将存储的目标区块的校验块发送给目标共识节点。
在一实施方式中,该校验块获取请求除了指示需要获取目标区块的校验块之外,还指示需要获取参考区块的区块头。参考区块为区块链上目标区块的下一个区块,即区块高度比目标区块大1的区块;参考区块的区块头包括基于目标区块对应的K个校验块构建的梅克尔树的树根。目标共识节点在从见证网络中的业务节点获取到目标区块的校验块以及参考区块的区块头之后,检测校验块是否与参考区块的区块头包括的梅克尔树的树根相匹配,若相匹配则确定该校验块有效,可用于恢复目标区块;反之若不相匹配则舍弃该校验块。这样可以提高恢复得到的目标区块的正确性,还可以避免无用的重复操作,提高目标区块的恢复效率。
在另一实施方式中,该校验块获取请求除了指示需要获取目标区块的校验块以及参考区块的区块头之外,还指示需要获取目标区块的校验块的Merkle路径。该Merkle路径即基于目标区块对应的K个校验块构建的梅克尔树中从树根节点到该校验块对应的节点的路径,是业务节点在从共识节点同步目标区块的区块数据时获取得到。目标共识节点在从见证网络中的业务节点获取到目标区块的校验块、该校验块的Merkle路径以及参考区块的区块头之后,检测该校验及其Merkle路径是否与参考区块的区块头包括的梅克尔树的树根相匹配,若相匹配则确定该校验块有效,可用于恢复目标区块;反之若不相匹配则舍弃该校验块。
S702、基于编码矩阵以及从见证网络中的业务节点获取到的校验块确定数据恢复参考矩阵。
本申请实施例中,基于编码矩阵以及从见证网络中的业务节点获取到的有效校验块确定数据恢复参考矩阵。
方式1,当从见证网络中的业务节点获取到目标区块的全部K个校验块,且K个校验块均有效时,从目标区块对应的编码矩阵获取该K个校验块对应的矩阵元素,并基于获取的K个校验块对应的矩阵元素确定数据恢复参考矩阵。
如前文所述,该K个校验块中的每一个校验块Ci(i为1-K中的任意一个)均是基于编码矩阵包括的编码参数矩阵的一行元素以及目标区块的N个数据块生成的,如图5所示,例如校验块C1是基于编码参数矩阵的第一行行元素(M11、M12、......、M1N)以及数据块矩阵(D1、D2、......、DN)得到,即校验块C1与编码参数矩阵的第一行元素(M11、M12、......、M1N)具有对应关系。也即是说,编码矩阵中与该K个校验块对应的矩阵元素,为编码矩阵包括的编码参数矩阵中的元素,可以直接将该编码参数矩阵(如图5中的503)确定为数据恢复参考矩阵。
其中,该编码参数矩阵为编码矩阵的子矩阵,这样确定的数据恢复参考矩阵为可逆的矩阵。在一实施方式中,K与N相等,此时确定的数据恢复参考矩阵为编码矩阵的一个K*K(或者说N*N)的子方阵,这样可以有效确保数据恢复参考矩阵的可逆性。在其他可行的实施方式中,K和N可以和M(共识网络中的共识节点的数量)相等。
方式2,当从见证网络中的业务节点只获取到目标区块的K个校验块中的X(X小于K)个有效校验块时,从共识网络中的其他共识节点(任意一个存储有完整目标区块的共识节点)获取目标区块,由于此时共识网络中的共识节点无法达成一致性共识,其他共识节点存储的目标区块的正确性(或者说可用性)无法确定,所以不能直接使用从其他共识节点获取到的目标区块。在从其他共识节点获取到其存储的目标区块之后,将获取到的目标区块进行序列化处理,并对序列化结果进行拆分得到N个数据块(拆分方式需要与校验 块生成及存储阶段中对目标区块的拆分方式一致);从拆分得到的N个数据块中随机获取K-X个数据块,然后从目标区块对应的编码矩阵获取该X个校验块和该K-X个数据块对应的矩阵元素,并基于获取的该X个校验块和该K-X个数据块对应的矩阵元素确定数据恢复参考矩阵。
在一实施方式中,可以根据校验块Ci(i为1-K中的任意一个)与编码矩阵包括的编码参数矩阵的行元素之间的对应关系,获取编码参数矩阵中该X个校验块对应的行元素;根据该K-X个数据块在该N个数据块组成的数据块矩阵(即校验块生成及存储阶段中针对目标区块的N个数据块组成的数据块矩阵,如图5中的504,即在确定目标区块的校验块阶段中将该N个数据块组成的一个N*1的数据块矩阵)中的行位置,获取编码矩阵包括的N*N单位矩阵(如图5中的502)中的相应行元素;然后基于获取到的编码参数矩阵中该X个校验块对应的行元素以及N*N单位矩阵中该K-X个数据块对应的行元素确定数据恢复参考矩阵。
例如,假设X取值为K-3,且该X个校验块为目标区块的K个校验块中的前X个校验块C1、C2、......、CX;此时K-X为3,假设随机选取的3个数据块为D2、DN-1和DN,则确定的数据恢复参考矩阵如图8中的801所示,数据恢复参考矩阵801包括802和803两部分,802是由图5中502所示的单位矩阵中数据块D2、DN-1和DN对应的第二、第N-1以及第N行元素组成,803是由图5中503所示的编码参数矩阵中数据块校验块C1、C2、......、CX对应的第一至第X行元素组成。
采用上述方式确定的数据恢复参考矩阵为编码矩阵的子矩阵,故确定的数据恢复参考矩阵为可逆的矩阵。在一实施方式中,K与N相等,此时确定的数据恢复参考矩阵为编码矩阵的一个K*K(或者说N*N)的子方阵,这样可以有效确保数据恢复参考矩阵的可逆性。在其他可行的实施方式中,K和N可以和G(共识网络中的共识节点的数量)相等。
S703、基于数据恢复参考矩阵以及从见证网络中的业务节点获取到的校验块恢复得到目标区块。
本申请实施例中,基于数据恢复参考矩阵以及从见证网络中的业务节点获取到的有效校验块恢复得到目标区块。
对应上述确定数据恢复参考矩阵的两种实现方式,步骤S702也存在两种实现方式:
方式1,在采用上述方式1确定出数据恢复参考矩阵之后,确定数据恢复参考矩阵的逆矩阵,然后基于该数据恢复参考矩阵的逆矩阵以及获取到的目标区块的K个校验块恢复得到目标区块。
在一实施方式中,将获取到的目标区块的K个校验块排列成一个K*1的数据矩阵(例如图9中901所示),将该数据恢复参考矩阵的逆矩阵与该校验块矩阵进行矩阵相乘即可得到由目标区块的N个数据块构成的数据块矩阵(D1、D2、......、DN),然后基于该数据块矩阵(D1、D2、......、DN)即可恢复出完整的目标区块。
方式2,在采用上述方式2确定出数据恢复参考矩阵之后,确定数据恢复参考矩阵的逆矩阵,然后基于该数据恢复参考矩阵的逆矩阵、获取到的目标区块的X个校验块以及随机获取的目标区块的K-X个数据块恢复得到目标区块。
在一实施方式中,将随机获取的目标区块的K-X个数据块以及获取到的目标区块的X个校验块排列成一个K*1的数据矩阵(如图9中902所示,对应上述方式2中的例子确定的),将该数据恢复参考矩阵的逆矩阵与该校验块矩阵进行矩阵相乘即可得到由目标区块 的N个数据块构成的数据块矩阵(D1、D2、......、DN),然后基于该数据块矩阵(D1、D2、......、DN)即可恢复出完整的目标区块。
在一实施方式中,为保证恢复出的目标区块的准确性,可以检测基于数据恢复参考矩阵的逆矩阵、X个校验块以及K-X个数据块恢复得到的目标区块,与从共识网络中的共识节点获取到的目标区块是否一致;若一致,则确定目标区块恢复成功;反之,若不一致,则表明从其他共识节点获取到的目标区块是不正确的,恢复出的目标区块也是不正确的(甚至此情况下根本无法恢复出区块),此时可以再次从其他共识节点(不同于之前的共识节点)获取其存储的目标区块,并采用上述方式恢复出目标区块,直至恢复出的目标区块与从共识节点获取到的目标区块一致。在其他可行的实施方式中,可以每次从多个共识节点获取其存储的目标区块,并对获取的多个目标区块中占比最大的区块进行处理,例如从5个共识节点获取其存储的目标区块,如果其中有四个区块一样,而另一个区块不一样,则对该一样的区块进行处理。这样可以在一定程度上保证获取的目标区块的准确性,以保证目标区块的恢复成功性。
上述恢复原理如下式所示:
P′=P*L′
P′*L′(-1)=P*L′*L′(-1)=P*(L′*L′(-1))=P
其中,P表示区块的N个数据块构成的数据块矩阵;P′表示上述方式1中将获取到的K个校验块排列成的数据矩阵,或者表示上述方式2中将随机获取的K-X个数据块以及获取到的X个校验块排列成的数据矩阵;L表示上述确定的数据恢复参考矩阵,L′(-1)表示L的逆矩阵,L′*L′(-1)为单位矩阵。P′=P*L′,如利用图8所示的数据恢复参考矩阵乘以如图5中504所示的由N个数据块构成的数据块矩阵,即可得到如图9中902所示的将随机获取的K-X个数据块以及获取到的X个校验块排列成的数据矩阵。
采用上述方式,目标共识节点可以恢复出其缺失的全部区块,当目标共识节点为新加入的共识节点时,其也可以完成区块链上所有区块的同步。
本申请实施例在分层区块链网络的基础上,提供了一种基于纠删码的保证区块链数据可用性的方案,既能够保证区块链上的保密交易不会被暴露给共识节点以外的任何节点(业务节点只能同步其可见的交易),也能够在共识网络处于不可用状态,且基于业务节点存储的区块数据无法完成区块的恢复时,也能够基于业务节点存储的校验块成功恢复出区块,并且可以有效保证恢复出的区块的可用性。
需要说明的是,用于执行上述方法实施例中各步骤的执行主体可以是由硬件构成,也可以是由软件构成,还可以是由软硬件结合构成。另外,在本申请的具体实施方式中,涉及到区块链、区块、区块头、区块体、交易数据等相关的数据,所涉及使用到的数据均是经过用户授权的。当本申请以上实施例运用到具体产品或技术中时,所涉及使用到的数据需要获得用户许可或者同意,且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准。
请参阅图10,图10为本申请实施例提供的一种数据处理装置的结构示意图。本申请实施例中所描述的装置包括处理单元1001、收发单元1002和存储单元1003,该数据处理装置应用于区块链网络中,所述区块链网络包括见证网络和共识网络,所述见证网络由多个业务节点组网构成,所述共识网络由多个共识节点组网构成,所述见证网络和所述共识网络建立有通信连接。
在可行的实施例中,该数据处理装置可以是对应于前文所述的共识网络中的目标共识节点,其中:
所述处理单元1001,用于在确定需要基于目标区块的校验块来恢复所述目标区块时,通过所述收发单元1002从所述见证网络中的业务节点获取所述目标区块的校验块;
所述处理单元1001,还用于基于编码矩阵以及从所述见证网络中的业务节点获取到的校验块确定数据恢复参考矩阵;
所述处理单元1001,还用于基于所述数据恢复参考矩阵以及从所述见证网络中的业务节点获取到的校验块恢复得到所述目标区块;
其中,所述目标区块为所述共识网络中的共识节点维护的区块链上的区块;所述业务节点存储的所述目标区块的校验块,是所述业务节点在从所述共识网络中的共识节点同步所述目标区块的相关区块数据时获取得到;所述校验块是所述共识网络中的共识节点利用所述编码矩阵对所述目标区块进行编码得到;所述校验块用于恢复所述目标区块。
在一实施例中,所述处理单元1001,还用于若检测到需要恢复所述目标区块,且所述共识网络中存在异常的共识节点所占的比例超过设定比例,以及所述见证网络中的业务节点未存储所述目标区块的全部区块数据,则确定需要基于所述目标区块的校验块来恢复所述目标区块。
在一实施例中,所述目标区块的校验块为K个,K为大于1的正整数;所述处理单元1001基于编码矩阵以及从所述见证网络中的业务节点获取到的校验块确定数据恢复参考矩阵,基于所述数据恢复参考矩阵以及从所述见证网络中的业务节点获取到的校验块恢复得到所述目标区块时,具体用于:
当从所述见证网络中的业务节点获取到所述目标区块的K个校验块时,从所述编码矩阵获取所述K个校验块对应的矩阵元素;基于获取的所述K个校验块对应的矩阵元素确定数据恢复参考矩阵,并确定所述数据恢复参考矩阵的逆矩阵;基于所述数据恢复参考矩阵的逆矩阵以及所述K个校验块恢复得到所述目标区块。
当从所述见证网络中的业务节点获取到所述目标区块的X个校验块时,从所述共识网络中的共识节点获取所述目标区块;X为小于K的正整数;将获取到的目标区块进行序列化处理,并对序列化结果进行拆分得到N个数据块;N为大于1的正整数;从拆分得到的N个数据块中获取K-X个数据块;从所述编码矩阵获取所述X个校验块和所述K-X个数据块对应的矩阵元素,并基于获取的所述X个校验块和所述K-X个数据块对应的矩阵元素确定数据恢复参考矩阵;确定所述数据恢复参考矩阵的逆矩阵,并基于所述数据恢复参考矩阵的逆矩阵、所述X个校验块以及所述K-X个数据块恢复得到所述目标区块。
在一实施例中,所述处理单元1001还用于:检测基于所述数据恢复参考矩阵的逆矩阵、所述X个校验块以及所述K-X个数据块恢复得到的目标区块,与从所述共识网络中的共识节点获取到的目标区块是否一致;若一致,则确定所述目标区块恢复成功。
在一实施例中,所述目标区块的校验块为K个,K为大于1的正整数;所述处理单元1001还用于:通过所述收发单元1002从所述见证网络中的业务节点获取参考区块的区块头;所述参考区块为所述区块链上所述目标区块的下一个区块,所述参考区块的区块头包括基于所述目标区块对应的K个校验块构建的梅克尔树的树根;将获取的目标区块的校验块中,与所述参考区块的区块头包括的梅克尔树的树根不相匹配的校验块舍弃。也即是说:后续是基于编码矩阵以及获取到的与参考区块的区块头包括的梅克尔树的树根相匹配的 校验块确定数据恢复参考矩阵,以及是基于数据恢复参考矩阵以及获取到的与参考区块的区块头包括的梅克尔树的树根相匹配的校验块恢复得到所述目标区块。
在一实施例中,所述处理单元1001还用于:将第一区块进行序列化处理,并对序列化结果进行拆分得到N个数据块;所述第一区块为所述区块链上的任意一个区块;N为大于1的正整数;将拆分得到的N个数据块组成一个N*1的数据块矩阵;利用所述编码矩阵对所述数据块矩阵进行编码,得到编码结果;所述编码结果包括K个校验块以及拆分得到的N个数据块;K为大于1的正整数;通过存储单元1003存储所述K个校验块中的全部或者部分校验块。
在一实施例中,所述共识网络由G个共识节点组网构成,G为大于1的正整数,K与G相等;所述处理单元1001通过存储单元1003存储所述K个校验块中的全部或者部分校验块时,具体用于:从所述K个校验块中确定排列标识与数据处理装置(或者说目标共识节点)在所述共识网络中的排列标识相匹配的匹配校验块;通过存储单元1003存储所述匹配校验块。
在一实施例中,所述处理单元1001还用于:对所述K个校验块中的每一个校验块进行哈希计算,得到K个哈希值;基于所述K个哈希值构建梅克尔树,并将构建的梅克尔树的树根加入第二区块的区块头中;所述第二区块为所述区块链上所述第一区块的下一个区块。
在一实施例中,所述收发单元1002,还用于接收目标业务节点发送的区块同步请求,所述区块同步请求携带同步区块高度以及所述目标业务节点的节点标识;所述目标业务节点为所述见证网络中的任意一个业务节点;
所述处理单元1001还用于:从所述区块链上确定与所述同步区块高度相匹配的匹配区块,并获取所述匹配区块的区块头以及所述匹配区块包括的所述目标业务节点具有访问权限的交易数据;获取所述K个校验块中与所述节点标识相匹配的匹配校验块;
所述收发单元1002,还用于将所述匹配区块的区块头、所述具有访问权限的交易数据以及所述匹配校验块发送给所述目标业务节点。
在可行的实施例中,该数据处理装置可以是对应于前文所述的见证网络中的目标业务节点,其中:
所述处理单元1001,用于通过所述收发单元1002向所述共识网络中的共识节点发送区块同步请求;所述区块同步请求携带同步区块高度以及数据处理装置(或者说目标业务节点)的节点标识;所述同步区块高度为需要同步的目标区块的区块高度,所述目标区块为所述共识网络中的共识节点维护的区块链上的区块;所述区块同步请求用于请求所述共识节点返回所述目标区块的相关数据;
所述收发单元1002,还用于接收所述共识节点返回的所述目标区块的相关数据;所述相关数据包括所述目标区块的区块头、所述目标区块包括的所述数据处理装置(或者说目标业务节点)具有访问权限的交易数据以及所述目标区块对应的K个校验块中与所述节点标识相匹配的匹配校验块;所述K个校验块是利用编码矩阵对所述目标区块进行编码得到;K为大于1的正整数;
存储单元1003,用于存储所述目标区块的相关数据;其中,存储的所述匹配校验块用于供所述共识网络中的共识节点恢复所述目标区块时使用。
在一实施例中,所述收发单元1002,还用于接收所述共识网络中的目标共识节点发送 的关于所述目标区块的校验块获取请求;所述校验块获取请求是所述目标共识节点在确定需要基于所述目标区块的校验块来恢复所述目标区块时向所述见证网络中的业务节点广播的;
所述处理单元1001,还用于通过所述收发单元1002将存储的所述目标区块对应的所述匹配校验块发送给所述共识节点,以使所述目标共识节点基于所述匹配校验块恢复所述目标区块。
在一实施例中,所述处理单元1001还用于:获取从所述共识网络中的共识节点同步的参考区块的区块头,所述参考区块为所述区块链上所述目标区块的下一个区块,所述参考区块的区块头包括基于所述目标区块对应的K个校验块构建的梅克尔树的树根;若所述相关数据中的所述匹配校验块,与所述参考区块的区块头包括的梅克尔树的树根相匹配,则通过存储单元1003存储所述匹配校验块。
可以理解的是,本申请实施例所描述的数据处理装置的各功能单元的功能可根据上述方法实施例中的方法具体实现,其具体实现过程可以参照上述方法实施例中的相关描述,此处不再赘述。
本申请实施例中,共识节点生成区块的校验块,并在业务节点同步区块时,将区块的校验块与区块的相关区块数据一起同步给业务节点,而在共识节点需要恢复区块时,从业务节点获取需要恢复的区块的校验块,即可基于获取到的校验块成功恢复出区块。采用此方式,可以在共识网络处于不可用状态,且基于业务节点存储的区块数据无法完成区块的恢复时,也能够基于业务节点存储的校验块成功恢复出区块,并且可以有效保证恢复出的区块的可用性。
在可行的实施例中,本申请实施例提供的数据处理装置可以采用软件方式实现,数据处理装置可以存储在存储器中,其可以是程序和插件等形式的软件,并包括一系列的单元,包括处理单元、通信单元和存储单元;其中,处理单元、通信单元和存储单元用于实现本申请实施例提供的基于区块链网络的数据处理方法。
在其它可行的实施例中,本申请实施例提供的数据处理装置也可以采用软硬件结合的方式实现,作为示例,本申请实施例提供的数据处理装置可以是采用硬件译码处理器形式的处理器,其被编程以执行本申请实施例提供的基于区块链网络的数据处理方法,例如,硬件译码处理器形式的处理器可以采用一个或多个应用专用集成电路(ASIC,Application Specific Integrated Circuit)、DSP、可编程逻辑器件(PLD,Programmable Logic Device)、复杂可编程逻辑器件(CPLD,Complex Programmable Logic Device)、现场可编程门阵列(FPGA,Field-Programmable Gate Array)或其他电子元件。
请参阅图11,图11为本申请实施例提供的一种计算机设备的结构示意图。本申请实施例中所描述的计算机设备包括:处理器1101、通信接口1102及存储器1103。其中,处理器1101、通信接口1102及存储器1103可通过总线或其他方式连接,本申请实施例以通过总线连接为例。
其中,处理器1101(或称CPU(Central Processing Unit,中央处理器))是计算机设备的计算核心以及控制核心,其可以解析计算机设备内的各类指令以及处理计算机设备的各类数据,例如:CPU可以用于解析用户向计算机设备所发送的开关机指令,并控制计算机设备进行开关机操作;再如:CPU可以在计算机设备内部结构之间传输各类交互数据,等等。通信接口1102可选的可以包括标准的有线接口、无线接口(如Wi-Fi、移动通信接口 等),受处理器1101的控制用于收发数据。存储器1103(Memory)是计算机设备中的记忆设备,用于存放程序和数据。可以理解的是,此处的存储器1103既可以包括计算机设备的内置存储器,当然也可以包括计算机设备所支持的扩展存储器。存储器1103提供存储空间,该存储空间存储了计算机设备的操作***,可包括但不限于:Android***、iOS***、Windows Phone***等等,本申请对此并不作限定。
在本申请实施例中,该计算机设备应用于区块链网络中,所述区块链网络包括见证网络和共识网络,所述见证网络由多个业务节点组网构成,所述共识网络由多个共识节点组网构成,所述见证网络和所述共识网络建立有通信连接。
在可行的实施例中,该计算机设备可以是对应于前文所述的共识网络中的目标共识节点,其中,处理器1101通过运行存储器1103中的可执行程序代码,执行如下操作:
在确定需要基于目标区块的校验块来恢复所述目标区块时,通过通信接口1102从所述见证网络中的业务节点获取所述目标区块的校验块;基于编码矩阵以及从所述见证网络中的业务节点获取到的校验块确定数据恢复参考矩阵;基于所述数据恢复参考矩阵以及从所述见证网络中的业务节点获取到的校验块恢复得到所述目标区块;
其中,所述目标区块为所述共识网络中的共识节点维护的区块链上的区块;所述业务节点存储的所述目标区块的校验块,是所述业务节点在从所述共识网络中的共识节点同步所述目标区块的相关区块数据时获取得到;所述校验块是所述共识网络中的共识节点利用所述编码矩阵对所述目标区块进行编码得到;所述校验块用于恢复所述目标区块。
在一实施例中,处理器1101还用于:若检测到需要恢复所述目标区块,且所述共识网络中存在异常的共识节点所占的比例超过设定比例,以及所述见证网络中的业务节点未存储所述目标区块的全部区块数据,则确定需要基于所述目标区块的校验块来恢复所述目标区块。
在一实施例中,所述目标区块的校验块为K个,K为大于1的正整数;处理器1101基于编码矩阵以及从所述见证网络中的业务节点获取到的校验块确定数据恢复参考矩阵,基于所述数据恢复参考矩阵以及从所述见证网络中的业务节点获取到的校验块恢复得到所述目标区块时,具体用于:
当从所述见证网络中的业务节点获取到所述目标区块的K个校验块时,从所述编码矩阵获取所述K个校验块对应的矩阵元素;基于获取的所述K个校验块对应的矩阵元素确定数据恢复参考矩阵,并确定所述数据恢复参考矩阵的逆矩阵;基于所述数据恢复参考矩阵的逆矩阵以及所述K个校验块恢复得到所述目标区块。
当从所述见证网络中的业务节点获取到所述目标区块的X个校验块时,从所述共识网络中的共识节点获取所述目标区块;X为小于K的正整数;将获取到的目标区块进行序列化处理,并对序列化结果进行拆分得到N个数据块;N为大于1的正整数;从拆分得到的N个数据块中获取K-X个数据块;从所述编码矩阵获取所述X个校验块和所述K-X个数据块对应的矩阵元素,并基于获取的所述X个校验块和所述K-X个数据块对应的矩阵元素确定数据恢复参考矩阵;确定所述数据恢复参考矩阵的逆矩阵,并基于所述数据恢复参考矩阵的逆矩阵、所述X个校验块以及所述K-X个数据块恢复得到所述目标区块。
在一实施例中,处理器1101还用于:检测基于所述数据恢复参考矩阵的逆矩阵、所述X个校验块以及所述K-X个数据块恢复得到的目标区块,与从所述共识网络中的共识节点获取到的目标区块是否一致;若一致,则确定所述目标区块恢复成功。
在一实施例中,所述目标区块的校验块为K个,K为大于1的正整数;处理器1101还用于:通过通信接口1102从所述见证网络中的业务节点获取参考区块的区块头;所述参考区块为所述区块链上所述目标区块的下一个区块,所述参考区块的区块头包括基于所述目标区块对应的K个校验块构建的梅克尔树的树根;将获取的目标区块的校验块中,与所述参考区块的区块头包括的梅克尔树的树根不相匹配的校验块舍弃。也即是说:后续是基于编码矩阵以及获取到的与参考区块的区块头包括的梅克尔树的树根相匹配的校验块确定数据恢复参考矩阵,以及是基于数据恢复参考矩阵以及获取到的与参考区块的区块头包括的梅克尔树的树根相匹配的校验块恢复得到所述目标区块。
在一实施例中,处理器1101还用于:将第一区块进行序列化处理,并对序列化结果进行拆分得到N个数据块;所述第一区块为所述区块链上的任意一个区块;N为大于1的正整数;将拆分得到的N个数据块组成一个N*1的数据块矩阵;利用所述编码矩阵对所述数据块矩阵进行编码,得到编码结果;所述编码结果包括K个校验块以及拆分得到的N个数据块;K为大于1的正整数;通过存储器1103存储所述K个校验块中的全部或者部分校验块。
在一实施例中,所述共识网络由G个共识节点组网构成,G为大于1的正整数,K与G相等;处理器1101通过存储器1103存储所述K个校验块中的全部或者部分校验块时,具体用于:从所述K个校验块中确定排列标识与计算机设备(或者说目标共识节点)在所述共识网络中的排列标识相匹配的匹配校验块;通过存储器1103存储所述匹配校验块。
在一实施例中,处理器1101还用于:对所述K个校验块中的每一个校验块进行哈希计算,得到K个哈希值;基于所述K个哈希值构建梅克尔树,并将构建的梅克尔树的树根加入第二区块的区块头中;所述第二区块为所述区块链上所述第一区块的下一个区块。
在一实施例中,处理器1101还用于:通过通信接口1102接收目标业务节点发送的区块同步请求,所述区块同步请求携带同步区块高度以及所述目标业务节点的节点标识;所述目标业务节点为所述见证网络中的任意一个业务节点;从所述区块链上确定与所述同步区块高度相匹配的匹配区块,并获取所述匹配区块的区块头以及所述匹配区块包括的所述目标业务节点具有访问权限的交易数据;获取所述K个校验块中与所述节点标识相匹配的匹配校验块;通过通信接口1102将所述匹配区块的区块头、所述具有访问权限的交易数据以及所述匹配校验块发送给所述目标业务节点。
在可行的实施例中,该计算机设备可以是对应于前文所述的见证网络中的目标业务节点,其中,处理器1101通过运行存储器1103中的可执行程序代码,执行如下操作:
通过通信接口1102向所述共识网络中的共识节点发送区块同步请求;所述区块同步请求携带同步区块高度以及计算机设备(或者说目标业务节点)的节点标识;所述同步区块高度为需要同步的目标区块的区块高度,所述目标区块为所述共识网络中的共识节点维护的区块链上的区块;所述区块同步请求用于请求所述共识节点返回所述目标区块的相关数据;
通过通信接口1102接收所述共识节点返回的所述目标区块的相关数据;所述相关数据包括所述目标区块的区块头、所述目标区块包括的所述计算机设备(或者说目标业务节点)具有访问权限的交易数据以及所述目标区块对应的K个校验块中与所述节点标识相匹配的匹配校验块;所述K个校验块是利用编码矩阵对所述目标区块进行编码得到;K为大于1的正整数;
通过存储器1103存储所述目标区块的相关数据;其中,存储的所述匹配校验块用于供所述共识网络中的共识节点恢复所述目标区块时使用。
在一实施例中,处理器1101还用于:通过通信接口1102接收所述共识网络中的目标共识节点发送的关于所述目标区块的校验块获取请求;所述校验块获取请求是所述目标共识节点在确定需要基于所述目标区块的校验块来恢复所述目标区块时向所述见证网络中的业务节点广播的;
通过通信接口1102将存储的所述目标区块对应的所述匹配校验块发送给所述共识节点,以使所述目标共识节点基于所述匹配校验块恢复所述目标区块。
在一实施例中,处理器1101还用于:获取从所述共识网络中的共识节点同步的参考区块的区块头,所述参考区块为所述区块链上所述目标区块的下一个区块,所述参考区块的区块头包括基于所述目标区块对应的K个校验块构建的梅克尔树的树根;若所述相关数据中的所述匹配校验块,与所述参考区块的区块头包括的梅克尔树的树根相匹配,则通过存储器1103存储所述匹配校验块。
具体实现中,本申请实施例中所描述的处理器1101、通信接口1102及存储器1103可实现上述方法实施例中的基于区块链网络的数据处理方法,具体实现过程可以参照上述方法实施例中的相关描述,此处不再赘述。
本申请实施例中,共识节点生成区块的校验块,并在业务节点同步区块时,将区块的校验块与区块的相关区块数据一起同步给业务节点,而在共识节点需要恢复区块时,从业务节点获取需要恢复的区块的校验块,即可基于获取到的校验块成功恢复出区块。采用此方式,可以在共识网络处于不可用状态,且基于业务节点存储的区块数据无法完成区块的恢复时,也能够基于业务节点存储的校验块成功恢复出区块,并且可以有效保证恢复出的区块的可用性。
本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,当其在计算机上运行时,使得计算机实现如本申请实施例所述的基于区块链网络的数据处理方法。其具体实现方式可参考前文描述,此处不再赘述。
本申请实施例还提供了一种计算机程序产品,所述计算机程序产品包括计算机程序或计算机指令,所述计算机程序或计算机指令被处理器执行时实现如本申请实施例所述的方法基于区块链网络的数据处理。其具体实现方式可参考前文描述,此处不再赘述。
需要说明的是,对于前述的各个方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某一些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本申请所必须的。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:闪存盘、只读存储器(Read-Only Memory,ROM)、随机存取器(Random Access Memory,RAM)、磁盘或光盘等。
以上所揭露的仅为本申请部分实施例而已,当然不能以此来限定本申请之权利范围,因此依本申请权利要求所作的等同变化,仍属本申请所涵盖的范围。

Claims (17)

  1. 一种基于区块链网络的数据处理方法,其特征在于,所述区块链网络包括见证网络和共识网络,所述见证网络由多个业务节点组网构成,所述共识网络由多个共识节点组网构成,所述见证网络和所述共识网络建立有通信连接;所述方法包括:
    在确定需要基于目标区块的校验块来恢复所述目标区块时,从所述见证网络中的业务节点获取所述目标区块的校验块;
    基于编码矩阵以及从所述见证网络中的业务节点获取到的校验块确定数据恢复参考矩阵;
    基于所述数据恢复参考矩阵以及从所述见证网络中的业务节点获取到的校验块恢复得到所述目标区块;
    其中,所述目标区块为所述共识网络中的共识节点维护的区块链上的区块;所述业务节点存储的所述目标区块的校验块,是所述业务节点在从所述共识网络中的共识节点同步所述目标区块的相关区块数据时获取得到;所述校验块是所述共识网络中的共识节点利用所述编码矩阵对所述目标区块进行编码得到;所述校验块用于恢复所述目标区块。
  2. 如权利要求1所述的方法,其特征在于,所述方法还包括:
    若检测到需要恢复所述目标区块,且所述共识网络中存在异常的共识节点所占的比例超过设定比例,以及所述见证网络中的业务节点未存储所述目标区块的全部区块数据,则确定需要基于所述目标区块的校验块来恢复所述目标区块。
  3. 如权利要求1或2所述的方法,其特征在于,所述目标区块的校验块为K个,K为大于1的正整数;所述基于编码矩阵以及从所述见证网络中的业务节点获取到的校验块确定数据恢复参考矩阵,基于所述数据恢复参考矩阵以及从所述见证网络中的业务节点获取到的校验块恢复得到所述目标区块,包括:
    当从所述见证网络中的业务节点获取到所述目标区块的K个校验块时,从所述编码矩阵获取所述K个校验块对应的矩阵元素;
    基于获取的所述K个校验块对应的矩阵元素确定数据恢复参考矩阵,并确定所述数据恢复参考矩阵的逆矩阵;
    基于所述数据恢复参考矩阵的逆矩阵以及所述K个校验块恢复得到所述目标区块。
  4. 如权利要求1或2所述的方法,其特征在于,所述目标区块的校验块为K个,K为大于1的正整数;所述基于编码矩阵以及从所述见证网络中的业务节点获取到的校验块确定数据恢复参考矩阵,基于所述数据恢复参考矩阵以及从所述见证网络中的业务节点获取到的校验块恢复得到所述目标区块,包括:
    当从所述见证网络中的业务节点获取到所述目标区块的X个校验块时,从所述共识网络中的共识节点获取所述目标区块;X为小于K的正整数;
    将获取到的目标区块进行序列化处理,并对序列化结果进行拆分得到N个数据块;N为大于1的正整数;
    从拆分得到的N个数据块中获取K-X个数据块;
    从所述编码矩阵获取所述X个校验块和所述K-X个数据块对应的矩阵元素,并基于获取的所述X个校验块和所述K-X个数据块对应的矩阵元素确定数据恢复参考矩阵;
    确定所述数据恢复参考矩阵的逆矩阵,并基于所述数据恢复参考矩阵的逆矩阵、所述X个校验块以及所述K-X个数据块恢复得到所述目标区块。
  5. 如权利要求4所述的方法,其特征在于,所述方法还包括:
    检测基于所述数据恢复参考矩阵的逆矩阵、所述X个校验块以及所述K-X个数据块恢复得到的目标区块,与从所述共识网络中的共识节点获取到的目标区块是否一致;
    若一致,则确定所述目标区块恢复成功。
  6. 如权利要求1或2所述的方法,其特征在于,所述目标区块的校验块为K个,K为大于1的正整数;所述方法还包括:
    从所述见证网络中的业务节点获取参考区块的区块头;所述参考区块为所述区块链上所述目标区块的下一个区块,所述参考区块的区块头包括基于所述目标区块对应的K个校验块构建的梅克尔树的树根;
    将获取的目标区块的校验块中,与所述参考区块的区块头包括的梅克尔树的树根不相匹配的校验块舍弃。
  7. 如权利要求1所述的方法,其特征在于,所述方法还包括:
    将第一区块进行序列化处理,并对序列化结果进行拆分得到N个数据块;所述第一区块为所述区块链上的任意一个区块;N为大于1的正整数;
    将拆分得到的N个数据块组成一个N*1的数据块矩阵;
    利用所述编码矩阵对所述数据块矩阵进行编码,得到编码结果;所述编码结果包括K个校验块以及拆分得到的N个数据块;K为大于1的正整数;
    在所述共识网络中的共识节点中存储所述K个校验块中的全部或者部分校验块。
  8. 如权利要求7所述的方法,其特征在于,所述共识网络由G个共识节点组网构成,G为大于1的正整数,K与G相等;所述在所述共识网络中的共识节点中存储所述K个校验块中的全部或者部分校验块,包括:
    从所述K个校验块中确定排列标识与一目标共识节点在所述共识网络中的排列标识相匹配的匹配校验块;
    在所述目标共识节点中存储所述匹配校验块。
  9. 如权利要求7所述的方法,其特征在于,所述方法还包括:
    对所述K个校验块中的每一个校验块进行哈希计算,得到K个哈希值;
    基于所述K个哈希值构建梅克尔树,并将构建的梅克尔树的树根加入第二区块的区块头中;所述第二区块为所述区块链上所述第一区块的下一个区块。
  10. 如权利要求7-9任一项所述的方法,其特征在于,所述方法还包括:
    接收目标业务节点发送的区块同步请求,所述区块同步请求携带同步区块高度以及所述目标业务节点的节点标识;所述目标业务节点为所述见证网络中的任意一个业务节点;所述同步区块高度为需要同步的目标区块的区块高度;
    从所述区块链上确定与所述同步区块高度相匹配的匹配区块,并获取所述匹配区块的区块头以及所述匹配区块包括的所述目标业务节点具有访问权限的交易数据;
    获取所述K个校验块中与所述节点标识相匹配的匹配校验块;
    将所述匹配区块的区块头、所述具有访问权限的交易数据以及所述匹配校验块发送给所述目标业务节点。
  11. 一种基于区块链网络的数据处理方法,其特征在于,所述区块链网络包括见证网 络和共识网络,所述见证网络由多个业务节点组网构成,所述共识网络由多个共识节点组网构成,所述见证网络和所述共识网络建立有通信连接;所述方法包括:
    向所述共识网络中的共识节点发送区块同步请求;所述区块同步请求携带同步区块高度以及目标业务节点的节点标识;所述同步区块高度为需要同步的目标区块的区块高度,所述目标区块为所述共识网络中的共识节点维护的区块链上的区块;所述区块同步请求用于请求所述共识节点返回所述目标区块的相关数据;
    接收所述共识节点返回的所述目标区块的相关数据;所述相关数据包括所述目标区块的区块头、所述目标区块包括的所述目标业务节点具有访问权限的交易数据以及所述目标区块对应的K个校验块中与所述节点标识相匹配的匹配校验块;所述K个校验块是利用编码矩阵对所述目标区块进行编码得到;K为大于1的正整数;
    存储所述目标区块的相关数据;其中,存储的所述匹配校验块用于供所述共识网络中的共识节点恢复所述目标区块时使用。
  12. 如权利要求11所述的方法,其特征在于,所述方法还包括:
    接收所述共识网络中的目标共识节点发送的关于所述目标区块的校验块获取请求;所述校验块获取请求是所述目标共识节点在确定需要基于所述目标区块的校验块来恢复所述目标区块时向所述见证网络中的业务节点广播的;
    将存储的所述目标区块对应的所述匹配校验块发送给所述目标共识节点,以使所述目标共识节点基于所述匹配校验块恢复所述目标区块。
  13. 如权利要求11或12所述的方法,其特征在于,所述方法还包括:
    获取从所述共识网络中的共识节点同步的参考区块的区块头,所述参考区块为所述区块链上所述目标区块的下一个区块,所述参考区块的区块头包括基于所述目标区块对应的K个校验块构建的梅克尔树的树根;
    若所述相关数据中的所述匹配校验块,与所述参考区块的区块头包括的梅克尔树的树根相匹配,则存储所述匹配校验块。
  14. 一种数据处理装置,其特征在于,包括用于执行如权利要求1-10中任一项所述的基于区块链网络的数据处理方法的单元,或者包括用于执行如权利要求11-13中任一项所述的基于区块链网络的数据处理方法的单元。
  15. 一种计算机设备,其特征在于,包括:处理器、通信接口和存储器,所述处理器、所述通信接口和所述存储器相互连接,其中,所述存储器存储有可执行程序代码,所述处理器用于调用所述可执行程序代码,实现如权利要求1-10中任一项所述的基于区块链网络的数据处理方法,或者,实现如权利要求11-13中任一项所述的基于区块链网络的数据处理方法。
  16. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机指令,当其在计算机上运行时,使得计算机实现如权利要求1-10中任一项所述的基于区块链网络的数据处理方法,或者,实现如权利要求11-13中任一项所述的基于区块链网络的数据处理方法。
  17. 一种计算机程序产品,其特征在于,所述计算机程序产品包括计算机程序或计算机指令,所述计算机程序或计算机指令被处理器执行时实现如权利要求1-10中任一项所述的基于区块链网络的数据处理方法,或者,实现如权利要求11-13中任一项所述的基于区块链网络的数据处理方法。
PCT/CN2023/091997 2022-05-19 2023-05-04 基于区块链网络的数据处理方法及相关产品 WO2023221772A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210545459.4 2022-05-19
CN202210545459.4A CN117130823A (zh) 2022-05-19 2022-05-19 基于区块链网络的数据处理方法及相关产品

Publications (1)

Publication Number Publication Date
WO2023221772A1 true WO2023221772A1 (zh) 2023-11-23

Family

ID=88834520

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/091997 WO2023221772A1 (zh) 2022-05-19 2023-05-04 基于区块链网络的数据处理方法及相关产品

Country Status (2)

Country Link
CN (1) CN117130823A (zh)
WO (1) WO2023221772A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019147295A1 (en) * 2018-01-29 2019-08-01 Ubiquicorp Limited Proof of majority block consensus method for generating and uploading a block to a blockchain
CN111444211A (zh) * 2020-03-26 2020-07-24 腾讯科技(深圳)有限公司 区块链共识节点校验方法、装置、设备以及存储介质
CN113190622A (zh) * 2021-03-16 2021-07-30 腾讯科技(深圳)有限公司 一种数据处理方法、装置、设备及存储介质
CN113254272A (zh) * 2021-06-09 2021-08-13 腾讯科技(深圳)有限公司 区块链网络的数据处理方法、装置、计算机设备和介质
CN113421097A (zh) * 2021-08-23 2021-09-21 腾讯科技(深圳)有限公司 一种数据处理方法、装置、计算机设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019147295A1 (en) * 2018-01-29 2019-08-01 Ubiquicorp Limited Proof of majority block consensus method for generating and uploading a block to a blockchain
CN111444211A (zh) * 2020-03-26 2020-07-24 腾讯科技(深圳)有限公司 区块链共识节点校验方法、装置、设备以及存储介质
CN113190622A (zh) * 2021-03-16 2021-07-30 腾讯科技(深圳)有限公司 一种数据处理方法、装置、设备及存储介质
CN113254272A (zh) * 2021-06-09 2021-08-13 腾讯科技(深圳)有限公司 区块链网络的数据处理方法、装置、计算机设备和介质
CN113421097A (zh) * 2021-08-23 2021-09-21 腾讯科技(深圳)有限公司 一种数据处理方法、装置、计算机设备及存储介质

Also Published As

Publication number Publication date
CN117130823A (zh) 2023-11-28

Similar Documents

Publication Publication Date Title
TWI705690B (zh) 分布式網路中進行主節點變更的系統
KR102237219B1 (ko) 분산 시스템 내의 네트워크 노드들 간의 합의 달성
US11294888B2 (en) Blockchain system and blockchain transaction data processing method based on ethereum
CN109189751B (zh) 基于区块链的数据同步方法及终端设备
US10701192B1 (en) System and method for ending view change protocol
CN114079660B (zh) 一种高性能分布式存储区块数据、时间戳、跨链通信与数据协同方法
US20200259633A1 (en) Data storage and verification
US11522698B2 (en) Method and system for byzantine fault-tolerance replicating of data
WO2019119929A1 (zh) 区块链共识方法、装置和***、标识信息处理方法和装置
US8234518B2 (en) Method for voting with secret shares in a distributed system
TWI717135B (zh) 用於結束視域變換協定的系統和方法
JP7047133B2 (ja) 符号化ブロックチェーンデータのインデックス化および復元
KR20200074911A (ko) 분산 시스템 내의 네트워크 노드를 위한 복구 프로세스의 수행
TWI715036B (zh) 檔案驗證方法、檔案驗證系統與檔案驗證伺服器
CN114391241A (zh) 具有可调整法定数量的区块链分片
CN111314060B (zh) 一种密钥更新方法、设备及存储介质
JP2022523217A (ja) 投票集計を伴うトポロジードリブンビザンチンフォールトトレラント合意プロトコル
JP7159348B2 (ja) 誤り訂正符号に基づく動的なブロックチェーンデータの記憶
CN111339551B (zh) 数据的验证方法及相关装置、设备
CN112395113A (zh) 实用拜占庭容错共识方法及装置、可读存储介质
WO2023221772A1 (zh) 基于区块链网络的数据处理方法及相关产品
CN116846888A (zh) 区块链网络的共识处理方法、装置、设备及存储介质
Peiris et al. Vault-a shared distributed and redundant storage solution
Wang et al. LgTTBFT: Effective Byzantine Fault Tolerance Algorithm Based on Structured Network and Trusted Execution Environment
CN117056131B (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: 23806724

Country of ref document: EP

Kind code of ref document: A1