WO2023160077A1 - Procédé et appareil de récupération de données de chaîne de blocs, et dispositif électronique - Google Patents

Procédé et appareil de récupération de données de chaîne de blocs, et dispositif électronique Download PDF

Info

Publication number
WO2023160077A1
WO2023160077A1 PCT/CN2022/135120 CN2022135120W WO2023160077A1 WO 2023160077 A1 WO2023160077 A1 WO 2023160077A1 CN 2022135120 W CN2022135120 W CN 2022135120W WO 2023160077 A1 WO2023160077 A1 WO 2023160077A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
data
blockchain
transaction data
types
Prior art date
Application number
PCT/CN2022/135120
Other languages
English (en)
Chinese (zh)
Inventor
俞本权
陆钟豪
卓海振
Original Assignee
蚂蚁区块链科技(上海)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 蚂蚁区块链科技(上海)有限公司 filed Critical 蚂蚁区块链科技(上海)有限公司
Publication of WO2023160077A1 publication Critical patent/WO2023160077A1/fr

Links

Images

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/1448Management of the data involved in backup or backup restore
    • 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/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1734Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1805Append-only file systems, e.g. using logs or journals to store data
    • G06F16/1815Journaling file systems

Definitions

  • One or more embodiments of this specification relate to the field of blockchain technology, and in particular, to a blockchain data recovery method and device, and electronic equipment.
  • Blockchain technology also known as distributed ledger technology, is an emerging technology in which several computing devices jointly participate in "bookkeeping" and jointly maintain a complete distributed database. Due to the characteristics of decentralization, openness and transparency, each computing device can participate in database records, and fast data synchronization between computing devices, blockchain technology has been widely used in many fields. to apply.
  • This specification proposes a blockchain data recovery method, which is applied to a node device; the node device is equipped with multiple storage systems for storing blockchain data.
  • the block chain data includes block transaction data and at least one other type of block chain data; the target storage system for storing the block transaction data in the plurality of storage systems supports the write-ahead log WAL model.
  • the method includes: reading a WAL log file corresponding to the block transaction data stored in the target storage system in response to the first event of recovering the other type of blockchain data; based on the WAL log The file restores the block transaction data, and executes the recovered block transaction data to generate the other types of block chain data; write the generated block chain data of other types into the Each of the multiple storage systems is used to store the other types of blockchain data.
  • the method further includes: determining whether the latest block number C among the block numbers corresponding to the other types of blockchain data stored in each storage system is smaller than the block number C stored in the target storage system The latest block number N among the block numbers corresponding to the block transaction data; if yes, the first event is generated.
  • the latest block number C is the minimum value of the latest block numbers corresponding to the other types of blockchain data stored in the storage systems; determine the other block numbers stored in the storage systems Whether the latest block number C corresponding to the type of blockchain data is less than the latest block number N corresponding to the block transaction data stored in the target storage system, it also includes: calculating the The minimum value of the latest block number corresponding to other types of blockchain data is used to obtain the latest block number C.
  • the data identification of the blockchain data stored in the plurality of storage systems includes a block number corresponding to the blockchain data.
  • the data identifiers of the blockchain data stored in the multiple storage systems adopt a unified data format.
  • the data identifier adopts the data format of the LSN log sequence number of the WAL log file.
  • reading the WAL log file corresponding to the block transaction data stored in the target storage system includes: respectively reading the blocks composed of the latest block number C and the latest block number N
  • the WAL log file corresponding to the block transaction data in the block represented by each block number in the number interval (C, N] restore the block transaction data based on the WAL log file, and execute the restored Block chain transactions to generate the other types of block chain data, including: corresponding to the block transaction data in the block represented by each block number in the block number interval (C, N] read WAL log file, restore the block transaction data in the block represented by each block number, and execute the recovered block transaction data to generate the block transaction data in the block represented by the block number
  • the other types of blockchain data corresponding to the block transaction data includes: respectively reading the blocks composed of the latest block number C and the latest block number N
  • the WAL log file corresponding to the block transaction data in the block represented by each block number in the number interval (C, N] restore the block transaction data based on the WAL log file, and execute the restored Block chain transactions
  • determine whether the latest block number C corresponding to the other types of blockchain data stored in each storage system is smaller than the latest block number N corresponding to the block transaction data stored in the target storage system Including: periodically determining whether the latest block number C corresponding to the other types of blockchain data stored in the storage systems is smaller than the latest block number N corresponding to the block transaction data stored in the target storage system; Or, in response to user-triggered instructions for restoring the other types of blockchain data, determine whether the latest block number C corresponding to the other types of blockchain data stored in the storage systems is less than the specified The latest block number N corresponding to the block transaction data stored in the target storage system.
  • the other types of blockchain data include a combination of one or more of the following: the block header data of the block corresponding to the block transaction data; the block header data corresponding to the block transaction data The transaction receipt; after the block transaction data is executed, the account status data corresponding to the block chain account in the block chain.
  • the method further includes: in response to the second event of restoring the block transaction data, restoring the block transaction data based on the WAL log file, and restoring the block transaction data data, written to the target storage system.
  • the method further includes: determining whether the number of files or the storage capacity of the WAL log files corresponding to the block transaction data stored in the target storage system reaches a threshold; if so, generating the second event.
  • determining whether the number of files or the storage capacity of the WAL log files corresponding to the block transaction data stored in the target storage system reaches a threshold includes: periodically determining the block transaction data stored in the target storage system Whether the number of files or the storage capacity of the WAL log file corresponding to the data reaches the threshold; or, in response to an instruction triggered by the user to restore the block transaction data, determine that the block transaction data corresponding to the target storage system Whether the number of files or storage capacity of WAL log files reaches the threshold.
  • This specification also proposes a blockchain data recovery device, which is applied to node equipment; the node equipment is equipped with multiple storage systems for storing blockchain data.
  • the block chain data includes block transaction data and at least one other type of block chain data; the target storage system for storing the block transaction data in the plurality of storage systems supports the write-ahead log WAL model.
  • the device includes: a reading module, which reads the WAL log file corresponding to the block transaction data stored in the target storage system in response to the first event of restoring the other types of blockchain data; Module, restores the block transaction data based on the WAL log file, and executes the recovered block transaction data to generate the other types of block chain data; writes the module, and generates the other types of block chain data
  • the block chain data are respectively written into each storage system used to store the other types of block chain data in the plurality of storage systems.
  • the device further includes: a first determining module, which determines whether the latest block number C among the block numbers corresponding to the other types of blockchain data stored in the storage systems is smaller than the target The latest block number N among the block numbers corresponding to the block transaction data stored in the storage system; if yes, the first event is generated.
  • a first determining module which determines whether the latest block number C among the block numbers corresponding to the other types of blockchain data stored in the storage systems is smaller than the target The latest block number N among the block numbers corresponding to the block transaction data stored in the storage system; if yes, the first event is generated.
  • the latest block number C is the minimum value of the latest block numbers corresponding to the other types of blockchain data stored in each storage system.
  • the determination module further: after determining whether the latest block number C corresponding to the other types of blockchain data stored in the storage systems is smaller than the latest block number C corresponding to the block transaction data stored in the target storage system Before number N, calculate the minimum value of the latest block numbers corresponding to the other types of blockchain data stored in each storage system to obtain the latest block number C.
  • the data identification of the blockchain data stored in the plurality of storage systems includes a block number corresponding to the blockchain data.
  • the data identifiers of the blockchain data stored in the multiple storage systems adopt a unified data format.
  • the data identifier adopts the data format of the LSN log sequence number of the WAL log file.
  • the reading module respectively read the blocks represented by the block numbers in the block number interval (C, N] formed by the latest block number C and the latest block number N]
  • the WAL log file corresponding to the block transaction data in the block the recovery module: based on the block transaction data corresponding to the block in the block represented by each block number in the block number interval (C, N] read WAL log file, restore the block transaction data in the blocks represented by the block numbers, and execute the recovered block transaction data to generate the block transaction data in the blocks represented by the block numbers
  • the other types of blockchain data corresponding to the block transaction data are examples of the block transaction data.
  • the first determining module periodically determine whether the latest block number C corresponding to the other types of blockchain data stored in each storage system is smaller than the block transaction stored in the target storage system The latest block number N corresponding to the data; or, in response to the user-triggered instruction for restoring the other types of blockchain data, determine the corresponding block number of the other types of blockchain data stored in the storage systems Whether the latest block number C is smaller than the latest block number N corresponding to the block transaction data stored in the target storage system.
  • the other types of blockchain data include a combination of one or more of the following: the block header data of the block corresponding to the block transaction data; the block header data corresponding to the block transaction data The transaction receipt; after the block transaction data is executed, the account status data corresponding to the block chain account in the block chain.
  • the writing module further: in response to the second event of restoring the block transaction data, restore the block transaction data based on the WAL log file, and restore the block transaction data The transaction data is written into the target storage system.
  • the device further includes: a second determining module, determining whether the number of files or the storage capacity of the WAL log files corresponding to the block transaction data stored in the target storage system reaches a threshold; if so, generating the second event.
  • a second determining module determining whether the number of files or the storage capacity of the WAL log files corresponding to the block transaction data stored in the target storage system reaches a threshold; if so, generating the second event.
  • the second determination module periodically determines whether the number of files or the storage capacity of the WAL log files corresponding to the block transaction data stored in the target storage system reaches a threshold; or, in response to user-triggered targeting The instruction for recovering the block transaction data determines whether the number of files or the storage capacity of the WAL log files corresponding to the block transaction data stored in the target storage system reaches a threshold.
  • Fig. 1 is a flow chart of a method for recovering blockchain data provided by an exemplary embodiment
  • Fig. 2 is a schematic structural diagram of an electronic device provided by an exemplary embodiment
  • Fig. 3 is a block diagram of a block chain data recovery device provided by an exemplary embodiment.
  • the steps of the corresponding methods are not necessarily performed in the order shown and described in this specification.
  • the method may include more or less steps than those described in this specification.
  • a single step described in this specification may be decomposed into multiple steps for description in other embodiments; multiple steps described in this specification may also be combined into a single step in other embodiments describe.
  • Blockchains are generally divided into three types: Public Blockchain, Private Blockchain and Consortium Blockchain.
  • Public Blockchain Private Blockchain
  • Consortium Blockchain there can be a combination of the above types, such as private chain + alliance chain, alliance chain + public chain, etc.
  • the public chain has the highest degree of decentralization. Participants joining the public chain (also known as nodes in the blockchain) can read data records on the chain, participate in transactions, and compete for the accounting rights of new blocks. Moreover, each node is free to join or exit the network and perform related operations.
  • the private chain the write permission of the network is controlled by an organization or institution, and the data read permission is regulated by the organization.
  • a private chain can be a weakly centralized system with strict restrictions on nodes and a small number of nodes. This type of blockchain is more suitable for internal use by specific institutions.
  • the alliance chain is a blockchain between the public chain and the private chain, which can realize "partial decentralization".
  • Each node in the consortium chain usually has a corresponding entity or organization; nodes join the network through authorization and form an alliance of stakeholders to jointly maintain the operation of the blockchain.
  • the blockchain is usually composed of several blocks. Time stamps corresponding to the creation time of the block are respectively recorded in these blocks, and all blocks form a time-ordered data chain in strict accordance with the time stamps recorded in the block.
  • the real data generated in the physical world it can be constructed into a standard transaction format supported by the blockchain, and then published to the blockchain, and the node devices in the blockchain will perform consensus processing on the received transactions , and after a consensus is reached, the node device in the blockchain as the bookkeeping node will package the transaction into a block and store the certificate persistently in the blockchain.
  • the consensus algorithms supported in the blockchain can include: the first type of consensus algorithm, that is, the consensus algorithm that node devices need to compete for the accounting rights of each round of accounting cycle, for example, proof of work (Proof of Work, POW ), proof of equity (Proof of Stake, POS), delegated proof of equity (Delegated Proof of Stake, DPOS) and other consensus algorithms; the second type of consensus algorithm is to pre-elect accounting nodes for each round of accounting cycle (no need to compete Bookkeeping rights) consensus algorithms; for example, consensus algorithms such as Practical Byzantine Fault Tolerance (PBFT).
  • PBFT Practical Byzantine Fault Tolerance
  • the node devices competing for the bookkeeping right can execute the transaction after receiving the transaction.
  • the node devices competing for bookkeeping rights there may be a node device that wins the current round of competition for bookkeeping rights and becomes a bookkeeping node.
  • the accounting node can package the received transaction with other transactions to generate the latest block, and send the generated latest block or the block header of the latest block to other node devices for consensus.
  • the node equipment with bookkeeping rights has been agreed before the current round of bookkeeping. Therefore, after the node device receives the transaction, if it is not the accounting node of the current round, it can send the transaction to the accounting node. For the bookkeeping nodes of this round, the transaction can be executed during or before the process of packaging the transaction with other transactions to generate the latest block. After the accounting node generates the latest block, it can send the latest block or the block header of the latest block to other node devices for consensus.
  • the bookkeeping nodes of this round can package the received transactions to generate the latest block, and will generate the latest block or the latest block
  • the block header is sent to other node devices for consensus verification. If other node devices receive the latest block or the block header of the latest block and verify that there is no problem, the latest block can be appended to the end of the original blockchain to complete the accounting process of the blockchain. In the process of verifying the new block or block header sent by the bookkeeping node, other nodes can also execute the transactions contained in the block.
  • Account In the field of blockchain, an important concept is account (Account); taking Ethereum as an example, Ethereum usually divides accounts into two types: external accounts and contract accounts; external accounts are accounts directly controlled by users, also known as It is a user account; while a contract account is an account created by a user through an external account and contains a contract code (that is, a smart contract).
  • External accounts are accounts directly controlled by users, also known as It is a user account
  • a contract account is an account created by a user through an external account and contains a contract code (that is, a smart contract).
  • a structure is usually used to maintain the account status of the account.
  • the state of the account associated with the transaction in the blockchain usually also changes.
  • the account structure usually includes fields such as Balance, Nonce, Code, and Storage. in:
  • the Balance field is used to maintain the current account balance of the account
  • the Nonce field is used to maintain the number of transactions of the account; it is a counter used to ensure that each transaction can only be processed once, effectively avoiding replay attacks;
  • the Code field is used to maintain the contract code of the account; in practical applications, only the hash value of the contract code is usually maintained in the Code field; therefore, the Code field is usually also called the Codehash field.
  • the Storage field is used to maintain the storage content of the account (the default field value is empty); for the contract account, an independent storage space is usually allocated to store the storage content of the contract account; the independent storage space is usually It is called the account storage of the contract account.
  • the storage content of the contract account is usually built into a data structure of MPT (Merkle Patricia Trie) tree and stored in the above-mentioned independent storage space; among them, the MPT tree constructed based on the storage content of the contract account is usually also called the Storage tree .
  • the Storage field usually only maintains the hash value of the root node of the Storage tree; therefore, the Storage field is usually also called the Storage Root hash field.
  • the field values of the Code field and the Storage field shown above are all null values.
  • the data structure of the Merkle tree is usually used; or, the data structure based on the Merkle tree is used to store and maintain the blockchain data.
  • the blockchain data that needs to be stored and maintained usually includes block data, account status data corresponding to the blockchain account in the blockchain; and the block data further includes block header data, The block transaction data in the block, and the transaction receipt corresponding to the block transaction data in the block, and so on. It should be noted that in practical applications, in addition to storing and maintaining blockchain data, node devices also need to store and maintain index data corresponding to blockchain data.
  • the MPT tree is a Merkle tree variant that combines the tree structure of the Trie dictionary tree.
  • Ethereum has designed three MPT trees, namely the MPT state tree, MPT transaction tree and MPT receipt tree. Among them, in addition to the above three MPT trees, there is actually a Storage tree built based on the storage content of the contract account.
  • the MPT state tree is an MPT tree organized by the account state (state) data of all accounts in the blockchain;
  • the MPT transaction tree is an MPT tree organized by the transaction (transaction) data in the blockchain;
  • the MPT receipt tree is the MPT tree organized by the transaction (receipt) receipt corresponding to each transaction generated after the transaction in the block is executed.
  • the hash values of the root nodes of the MPT state tree, MPT transaction tree and MPT receipt tree shown above will eventually be added to the block header of the corresponding block.
  • the MPT transaction tree and MPT receipt tree correspond to blocks, that is, each block has its own MPT transaction tree and MPT receipt tree.
  • the MPT state tree is a global MPT tree, which does not correspond to a specific block, but covers the account state data of all accounts in the blockchain.
  • the account status of the accounts (which can be external accounts or contract accounts) related to these executed transactions in the blockchain, usually It will also change accordingly.
  • the balances of the transfer-out account and transfer-in account related to the "transfer transaction” (that is, the field value of the Balance field of these accounts) are usually also Will change accordingly.
  • the node device After the transaction of the node device in the latest block generated by the blockchain is completed, because the account status in the current blockchain has changed, the node device needs to use the current account status data of all accounts in the blockchain. Build an MPT state tree to maintain the latest state of all accounts in the blockchain.
  • the node device needs to be based on all accounts in the blockchain
  • the latest account status data rebuilds an MPT status tree.
  • each block in the blockchain has a corresponding MPT state tree; the MPT state tree maintains all accounts in the blockchain after the transactions in the block are executed. account status.
  • the blockchain usually connects with various business systems outside the chain for multi-party data and workflow collaboration (independent of business); for example, a business system A connected to the blockchain, Relevant business data can be published to the blockchain to drive another business system B that is connected to the blockchain to perform further business processing based on the business data; and for different types of blockchain data, the multi-party data
  • the actual functions may be different from each other; when node devices store and maintain blockchain data, they usually carry multiple storage systems and store different types of blockchain data in the in different storage systems.
  • the node device can be equipped with three different storage systems, which store block data, state data (that is, the above account status data), and index data corresponding to the above two types of data (such as the hash of the above two types of data) value), which are stored in different storage systems.
  • state data that is, the above account status data
  • index data corresponding to the above two types of data such as the hash of the above two types of data
  • WAL copies of WAL are examples respectively.
  • the node device can combine block header data, block transaction data, transaction receipts corresponding to block transaction data, state data (that is, the above-mentioned account status data), and index data corresponding to the above four types of data (such as The hash values of the above 4 kinds of data) are stored in different storage systems; in this case, the node device can be equipped with 5 different storage systems, which respectively store block header data, block transaction The transaction receipt, state data corresponding to the data, and the index data corresponding to the above four types of data are stored in these five different storage systems.
  • each storage system can enable WAL (write ahead logging, pre-written log) mode.
  • the WAL mode is an efficient log algorithm.
  • all data modification for the storage system will be written into the WAL log file before being submitted to the storage system; then, through the checkpoint event triggered periodically or manually by the user, the The data stored in the WAL log file is modified and written to the storage system.
  • the blockchain ledger stored by the node device By enabling the WAL mode for the storage system on the node device, although data loss due to unwritten data can be prevented, the blockchain ledger stored by the node device often contains many different types of blockchain data. Stored in different storage systems; therefore, storing multiple WAL log files will increase the storage overhead of the node device; moreover, when the node device restores the data modification stored in multiple WAL log files to the storage system, it needs multiple times Executing the related recovery process will also increase the performance overhead of the node device.
  • this manual proposes a technical solution for recovering various blockchain data by using a WAL log file stored in the node device and corresponding to the blockchain transaction data.
  • the node device of the blockchain can be equipped with multiple storage systems for storing blockchain data.
  • the aforementioned block chain data may include block transaction data and at least one type of block chain data with other types;
  • the target storage system used to store the block transaction data in the above-mentioned multiple storage systems may support the write-ahead log WAL model.
  • the node device responds to the first event of recovering the above-mentioned other types of blockchain data, it can read the WAL log file corresponding to the block transaction data stored in the target storage system; then based on the read WAL The log file restores the above-mentioned block transaction data.
  • the restored block transaction data is further executed to generate the above-mentioned other types of block chain data; then, the generated above-mentioned other Types of blockchain data are respectively written into the storage systems used to store the other types of blockchain data in the above-mentioned multiple storage systems.
  • FIG. 1 is a flow chart of a blockchain data recovery method provided by an exemplary embodiment.
  • the method is applied to a block chain node device; wherein, the block chain data includes block transaction data and at least one other type of block chain data corresponding to the block transaction data; the plurality of stored
  • the target storage system used to store the block transaction data in the system supports the write-ahead log WAL mode.
  • the method comprises the steps of:
  • Step 102 in response to the first event of recovering the other types of blockchain data, read the WAL log file corresponding to the block transaction data stored in the target storage system;
  • Step 104 recovering the block transaction data based on the WAL log file, and executing the recovered block transaction data to generate the other types of blockchain data;
  • Step 106 writing the generated blockchain data of other types into storage systems for storing the blockchain data of other types among the multiple storage systems.
  • the blockchain ledger stored by the node device usually includes various types of blockchain data.
  • the various types of blockchain data mentioned above may generally include block data, account status data corresponding to blockchain accounts in the blockchain, and so on.
  • the block data usually includes block header data and block body data; the above block body data further includes block transaction data in the block, and transaction receipts corresponding to the block transaction data in the block, etc. wait.
  • node devices in addition to the blockchain data listed above, node devices usually need to store and maintain index data corresponding to the above-mentioned various blockchain data.
  • the specific form of the above-mentioned index data is not particularly limited in this specification.
  • the content summary (such as hash value) of the above blockchain data can be used as the Index data, so that users can use the content summary of the above blockchain data as a query index to query and access related blockchain data in the blockchain ledger.
  • the data identifier (such as the data number) set by the blockchain system for the stored blockchain data can be specified.
  • the index data of the blockchain data users can use the data identification of the above blockchain data as a query index to query and access the relevant blockchain data in the blockchain ledger.
  • the node device can be equipped with multiple storage systems, and store different types of blockchain data in different storage systems.
  • the above-mentioned storage system can specifically include any form of storage system for persistent storage of blockchain data in the blockchain ledger; for example, in practical applications, the above-mentioned storage system can specifically be a node device carrying The database, file system, etc., are not particularly limited in this specification.
  • the above-mentioned block transaction data can be used as the "root data" of other types of blockchain data; when the node device stores the various types of blockchain data shown above, the above-mentioned block can be Transaction data and other types of blockchain data are stored in separate storage systems.
  • the node device can be equipped with five different storage systems, which respectively store the block transaction data, the block header data of the block corresponding to the block transaction data, the transaction receipt corresponding to the block transaction data, The state data and the index data corresponding to the above four types of data are stored in these five different storage systems.
  • the target storage system used to store "root data” (that is, block transaction data) in each storage system can open WAL model. After the WAL mode is turned on, all data modifications (such as writing new block transaction data) for the target storage system will be written to the target storage system in the form of a WAL log file before being submitted to the target storage system.
  • the WAL log buffer corresponding to the target storage system can also be a persistent storage; then, when the blockchain system triggers a checkpoint event corresponding to the above target storage system, the node device can respond to the checkpoint Event, and then modify the above "root data” data stored in the WAL log file, and restore it to the target storage system.
  • the above-mentioned checkpoint event refers to an event of performing data recovery on the blockchain data stored in the storage system based on the WAL log file.
  • the WAL mode may not be enabled, but cross-storage based on the WAL log files corresponding to the above-mentioned target storage systems.
  • Data recovery of the storage system that is, a storage system that does not enable the WAL mode can also perform data recovery through the corresponding WAL log files of other storage systems that enable the WAL mode.
  • the blockchain system can also checkpoint events of the above-mentioned other storage systems that have not opened the WAL mode; and when the blockchain system triggers the checkpoint events corresponding to the above-mentioned other storage systems, the node device can In response to the checkpoint event, read the WAL log file corresponding to the above-mentioned target storage system for data recovery calculation, and then based on the calculation results of the data recovery calculation, cross-storage system data for other types of blockchain data stored in the other storage systems mentioned above data recovery.
  • the process for the node device to recover the block transaction data stored in the above-mentioned target storage system, and the process for recovering other types of blockchain data stored in the above-mentioned other storage systems can be two
  • the procedures that are independent of each other are not particularly limited in the execution sequence of the two in this specification.
  • the node device can first perform the process of recovering the block transaction data stored in the above-mentioned target storage system, and then perform recovery of other types of blockchain data stored in the above-mentioned other storage systems
  • the process of recovering other types of blockchain data stored in the above-mentioned other storage systems can also be performed first, and then the process of recovering the block transaction data stored in the above-mentioned target storage system can be performed.
  • the process of recovering the block transaction data stored in the above-mentioned target storage system is also completed based on the WAL log file corresponding to the above-mentioned block transaction data; therefore, if the node device first executes the above-mentioned target The process of recovering the block transaction data stored in the storage system needs to temporarily not delete the WAL log file corresponding to the above block transaction data stored in the log buffer after the above block transaction data is restored; when the node device starts Execute the process of recovering other types of blockchain data stored in the above-mentioned other storage systems, and continue to restore other types of blockchain data stored in the above-mentioned other storage systems based on the above-mentioned WAL log files, and in After recovery is complete, delete the WAL log file from the log buffer.
  • the checkpoint event triggered by the blockchain system and corresponding to the above-mentioned other storage systems will be called “the first event”; the checkpoint event triggered by the blockchain system and corresponding to the above-mentioned target storage system , which will be referred to as the "second event”.
  • the trigger condition of the above-mentioned first event may generally include that the number of WAL log files corresponding to the block transaction data stored in the above-mentioned target storage system reaches a threshold ; Or, the storage capacity of the WAL log file corresponding to the block transaction data stored in the above target storage system reaches a threshold.
  • the threshold can trigger the blockchain system to generate the above-mentioned first event.
  • the trigger condition of the above-mentioned second event may specifically include that the latest block number C among the block numbers corresponding to the above-mentioned other types of blockchain data stored in the above-mentioned other storage systems is smaller than the block transaction data stored in the above-mentioned target storage system The latest block number N in the corresponding block number.
  • the latest block number C in the block numbers corresponding to the above-mentioned other types of blockchain data stored in the above-mentioned other storage systems is smaller than the block number C in the block number corresponding to the block transaction data stored in the above-mentioned target storage system
  • the latest block number N can trigger the blockchain system to generate the above-mentioned second event.
  • the following will use a specific embodiment to trigger the above-mentioned first event based on the blockchain system for the node device, and restore the other types of blockchain data stored in the above-mentioned other storage systems; and, the node device triggers the process based on the system
  • the process of recovering the block transaction data stored in the above-mentioned target storage system for the above-mentioned second event is described separately.
  • the node device when the node device restores other types of blockchain data stored in the above-mentioned other storage systems, it can periodically determine the above-mentioned other types of blocks stored in the above-mentioned other storage systems Whether the latest block number C corresponding to the chain data is smaller than the latest block number N corresponding to the block transaction data stored in the above-mentioned target storage system; if yes, the generation of the above-mentioned first event can be triggered.
  • the node device may preset a check period T of the checkpiont event, and then periodically check whether the above-mentioned other storage systems meet the triggering condition of the above-mentioned checkpiont event based on the period T.
  • the node device when the node device restores other types of blockchain data stored in the above-mentioned other storage systems, it can also respond to user-triggered Data recovery instructions to determine whether the latest block number C corresponding to the above-mentioned other types of blockchain data stored in the above-mentioned other storage systems is smaller than the latest block number N corresponding to the block transaction data stored in the above-mentioned target storage system ; If yes, it may trigger to generate the above-mentioned first event.
  • the user in addition to periodically checking whether the above-mentioned other storage systems meet the trigger conditions of the above-mentioned checkpiont event, the user can also trigger the node device to check the above-mentioned other storage systems by manually inputting recovery instructions.
  • the user may need to perform a data rollback operation on the above-mentioned other types of blockchain data stored in the above-mentioned other storage systems, and restore the data stored in the above-mentioned other storage systems
  • the above-mentioned other types of blockchain data are restored to the data version corresponding to a certain historical block; in this scenario, the user can trigger the node device to check whether the above-mentioned other storage systems meet the above-mentioned checkpoint by manually inputting the recovery command.
  • the trigger condition for the event is
  • the latest block number C corresponding to the above-mentioned other types of blockchain data stored in the above-mentioned other storage systems may specifically be the latest block number C corresponding to the above-mentioned other types of blockchain data stored in the above-mentioned other storage systems
  • the node device can first calculate the minimum value of the latest block number corresponding to the above-mentioned other types of blockchain data stored in the above-mentioned other storage systems, and obtain the above-mentioned latest block number C, It is further determined whether the above latest block number C is smaller than the latest block number N corresponding to the block transaction data stored in the target storage system.
  • the data identification of the blockchain data stored in each storage system may specifically include the above-mentioned The block number corresponding to the blockchain data; that is, the block number corresponding to the blockchain data can be directly added to the data identifier of the blockchain data; or, in the data identifier of the blockchain data, Add information indicating the block number to which the blockchain data corresponds.
  • the data identification of the blockchain data stored in each storage system carried by the node device can specifically adopt a unified data format, and in the unified data format adopted, carry the data corresponding to the blockchain data.
  • Block number or information indicating the block number corresponding to the blockchain data.
  • the above-mentioned data format is not particularly limited in this specification; for example, in one example, the data identification of the blockchain data stored in each storage system carried by the node device can uniformly use the LSN (Log Sequence Number, the data format of the log sequence number), and carry the block number corresponding to the blockchain data in the LSN of the WAL log file; or indicate the information of the block number corresponding to the blockchain data.
  • LSN Log Sequence Number, the data format of the log sequence number
  • the node device can respond to the first event by reading the above-mentioned latest block number C and the above-mentioned latest block number C from the log buffer corresponding to the above-mentioned target storage system respectively.
  • the recovered block transaction data can be further executed, and by re-executing the transaction, generate The above-mentioned other types of blockchain data corresponding to the block transaction data in the block represented by each block number in the above-mentioned block number interval (C, N].
  • the node device is equipped with five different storage systems, which respectively store the block transaction data, the block header data of the block corresponding to the block transaction data, the transaction receipt corresponding to the block transaction data,
  • the state data and the index data corresponding to the above four types of data are stored in these five different storage systems; among them, the target storage system that stores the above block transaction data has turned on the WAL mode; then for the above other types of blocks
  • the target storage system that stores the above block transaction data has turned on the WAL mode; then for the above other types of blocks
  • C, N block number in the above block number interval
  • the corresponding state data and corresponding index data are restored separately.
  • the node device when the node device restores the block transaction data stored in the above target storage system, it can periodically determine the WAL log file corresponding to the block transaction data stored in the above target storage system Whether the number of files or the storage capacity reaches the threshold; if yes, the above-mentioned second event may be triggered to be generated.
  • the node device when the node device recovers the block transaction data stored in the target storage system, it may also respond to an instruction manually triggered by the user to restore the above block transaction data to determine Whether the number of files or the storage capacity of the WAL log files corresponding to the block transaction data stored in the target storage system reaches a threshold; if yes, the generation of the second event above may be triggered.
  • the user in addition to periodically checking whether the above-mentioned target storage system meets the trigger conditions of the above-mentioned checkpoint event, the user can also trigger the node device to check whether the above-mentioned target storage system meets The trigger condition of the above checkpiont event; for example, in some recovery scenarios, the user may need to perform a data rollback operation on the blockchain transaction data stored in the above target storage system, and restore the block transaction data stored in the above target storage system to a certain The data version corresponding to a historical block. In this scenario, the user may manually input a recovery command to trigger the node device to check whether the target storage system satisfies the trigger condition of the checkpiont event.
  • the node device can respond to the second event and read the WAL log file corresponding to the block transaction data stored in the log buffer from the log buffer corresponding to the above-mentioned target storage system; and then , based on the read WAL log file, restore the block transaction data, and then write the restored block transaction data into the above target storage system.
  • the present application also provides device embodiments.
  • this specification also provides an embodiment of a block chain data recovery device.
  • the embodiment of the blockchain data recovery device in this specification can be applied to electronic equipment.
  • the device embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by reading the corresponding computer program instructions in the non-volatile memory into the memory for operation by the processor of the electronic device where it is located.
  • FIG. 2 it is a hardware structure diagram of the electronic equipment where the blockchain data recovery device in this manual is located, except for the processor, memory, network interface, and non-volatile memory shown in Figure 2
  • the electronic device where the device in the embodiment is located usually may also include other hardware according to the actual function of the electronic device, which will not be repeated here.
  • Fig. 3 is a block diagram of a block chain data recovery device shown in an exemplary embodiment of this specification.
  • the block chain data recovery device 30 can be applied in the aforementioned electronic equipment shown in FIG. 2, and the node device is equipped with multiple storage systems for storing block chain data; wherein, the The block chain data includes block transaction data and at least one other type of block chain data; the target storage system for storing the block transaction data in the plurality of storage systems supports the write-ahead log WAL mode; the The device 30 includes: a reading module 301, which reads the WAL log file corresponding to the block transaction data stored in the target storage system in response to the first event of restoring the other types of blockchain data; Module 302, restore the block transaction data based on the WAL log file, and execute the recovered block transaction data to generate the other types of block chain data; write module 303, the generated Other types of blockchain data are respectively written into the storage systems used to store the other types of blockchain data among the plurality of storage systems.
  • the device 30 further includes: a first determination module 304 (not shown in FIG. 3 ), which determines the number of block numbers corresponding to the other types of blockchain data stored in each storage system. Whether the latest block number C of the target storage system is smaller than the latest block number N in the block numbers corresponding to the block transaction data stored in the target storage system; if yes, the first event is generated.
  • a first determination module 304 (not shown in FIG. 3 ), which determines the number of block numbers corresponding to the other types of blockchain data stored in each storage system. Whether the latest block number C of the target storage system is smaller than the latest block number N in the block numbers corresponding to the block transaction data stored in the target storage system; if yes, the first event is generated.
  • the latest block number C is the minimum value of the latest block numbers corresponding to the other types of blockchain data stored in the storage systems.
  • the first determination module 304 further: after determining whether the latest block number C corresponding to the other types of blockchain data stored in the storage systems is smaller than the block number C corresponding to the block transaction data stored in the target storage system Before the latest block number N, calculate the minimum value of the latest block numbers corresponding to the other types of blockchain data stored in the storage systems to obtain the latest block number C.
  • the data identification of the blockchain data stored in the multiple storage systems includes the block number corresponding to the blockchain data.
  • the data identifiers of the blockchain data stored in the multiple storage systems adopt a unified data format.
  • the data identifier adopts the data format of the LSN log sequence number of the WAL log file.
  • the reading module 301 respectively reads the block number represented by each block number in the block number interval (C, N] formed by the latest block number C and the latest block number N]
  • the WAL log file corresponding to the block transaction data in the block The recovery module 302: based on the block in the block represented by each block number in the block number interval (C, N] read
  • the WAL log file corresponding to the transaction data restores the block transaction data in the blocks represented by the block numbers, and executes the recovered block transaction data to generate the block transaction data represented by the block numbers.
  • the other types of blockchain data corresponding to the block transaction data in the block are examples of the block transaction data in the block.
  • the first determination module 304 (not shown in FIG. 3 ): periodically determine the latest block number C corresponding to the other types of blockchain data stored in each storage system, whether is less than the latest block number N corresponding to the block transaction data stored in the target storage system; or, in response to the instruction triggered by the user to restore the other types of blockchain data, determine the Whether the latest block number C corresponding to the other types of blockchain data is smaller than the latest block number N corresponding to the block transaction data stored in the target storage system.
  • the other types of blockchain data include a combination of one or more of the following: block header data of the block corresponding to the block transaction data; The transaction receipt corresponding to the data; after the block transaction data is executed, the account status data corresponding to the block chain account in the block chain.
  • the writing module 303 further: in response to the second event of restoring the block transaction data, restore the block transaction data based on the WAL log file, and restore all The block transaction data is written into the target storage system.
  • the device 30 further includes: a second determination module 305 (not shown in FIG. 3 ), which determines the number of WAL log files corresponding to the block transaction data stored in the target storage system or Whether the storage capacity reaches a threshold; if so, generating the second event.
  • a second determination module 305 (not shown in FIG. 3 ), which determines the number of WAL log files corresponding to the block transaction data stored in the target storage system or Whether the storage capacity reaches a threshold; if so, generating the second event.
  • the second determination module 305 periodically determines whether the number of files or the storage capacity of the WAL log files corresponding to the block transaction data stored in the target storage system reaches a threshold; or, in response to the user
  • the triggered instruction for recovering the block transaction data determines whether the number of files or the storage capacity of the WAL log files corresponding to the block transaction data stored in the target storage system reaches a threshold.
  • a typical implementing device is a computer, which may take the form of a personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media player, navigation device, e-mail device, game control device, etc. desktops, tablets, wearables, or any combination of these.
  • a computer includes one or more processors (CPUs), input/output interfaces, network interfaces and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • Memory may include non-permanent storage in computer readable media, in the form of random access memory (RAM) and/or nonvolatile memory such as read-only memory (ROM) or flash RAM. Memory is an example of computer readable media.
  • RAM random access memory
  • ROM read-only memory
  • flash RAM flash random access memory
  • Computer-readable media including both permanent and non-permanent, removable and non-removable media, can be implemented by any method or technology for storage of information.
  • Information may be computer readable instructions, data structures, modules of a program, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by computing devices.
  • computer-readable media excludes transitory computer-readable media, such as modulated data signals and carrier waves.
  • first, second, third, etc. may be used in one or more embodiments of the present specification to describe various information, the information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of one or more embodiments of the present specification, first information may also be called second information, and similarly, second information may also be called first information. Depending on the context, the word “if” as used herein may be interpreted as “at” or "when” or "in response to a determination.”

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

L'invention concerne un procédé de récupération de données de chaîne de blocs, appliqué à un dispositif de nœud. Le dispositif de nœud transporte une pluralité de systèmes de stockage pour stocker des données de chaîne de blocs, les données de chaîne de blocs comprenant des données de transaction de bloc et au moins l'un d'autres types de données de chaîne de blocs, et un système de stockage cible, utilisé pour stocker les données de transaction de bloc, parmi la pluralité de systèmes de stockage prenant en charge un mode de journalisation anticipée d'écriture (WAL). Le procédé consiste à : en réponse à un premier événement pour récupérer d'autres types de données de chaîne de blocs, lire un fichier de journal WAL correspondant à des données de transaction de bloc stockées dans un système de stockage cible ; récupérer les données de transaction de bloc sur la base du fichier de journal WAL, et exécuter les données de transaction de bloc récupérées pour générer les autres types de données de chaîne de blocs ; et écrire respectivement les autres types de données de chaîne de blocs générées dans chaque système de stockage, utilisé pour stocker les autres types de données de chaîne de blocs, parmi la pluralité de systèmes de stockage.
PCT/CN2022/135120 2022-02-25 2022-11-29 Procédé et appareil de récupération de données de chaîne de blocs, et dispositif électronique WO2023160077A1 (fr)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210178105.0 2022-02-25
CN202210178105.0A CN114780285A (zh) 2022-02-25 2022-02-25 区块链数据恢复方法及装置、电子设备

Publications (1)

Publication Number Publication Date
WO2023160077A1 true WO2023160077A1 (fr) 2023-08-31

Family

ID=82423640

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135120 WO2023160077A1 (fr) 2022-02-25 2022-11-29 Procédé et appareil de récupération de données de chaîne de blocs, et dispositif électronique

Country Status (2)

Country Link
CN (1) CN114780285A (fr)
WO (1) WO2023160077A1 (fr)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117056131A (zh) * 2023-10-11 2023-11-14 腾讯科技(深圳)有限公司 基于区块链网络的数据处理方法及相关设备
CN117670330A (zh) * 2024-02-01 2024-03-08 中国信息通信研究院 基于区块链的交易处理方法和装置、电子设备和存储介质

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114780285A (zh) * 2022-02-25 2022-07-22 蚂蚁区块链科技(上海)有限公司 区块链数据恢复方法及装置、电子设备

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5485608A (en) * 1990-06-29 1996-01-16 Oracle Corporation Methods and apparatus for updating information in a computer system using logs and state identifiers
WO2017122060A1 (fr) * 2016-08-25 2017-07-20 Huawei Technologies India Pvt. Ltd. Récupération parallèle pour bases de données à disque partagé
CN111507720A (zh) * 2020-04-22 2020-08-07 腾讯科技(深圳)有限公司 基于区块链的数据快照方法、装置及计算机可读存储介质
CN112597153A (zh) * 2020-12-09 2021-04-02 杭州趣链科技有限公司 一种基于区块链的数据存储方法、装置及存储介质
CN114780285A (zh) * 2022-02-25 2022-07-22 蚂蚁区块链科技(上海)有限公司 区块链数据恢复方法及装置、电子设备

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5485608A (en) * 1990-06-29 1996-01-16 Oracle Corporation Methods and apparatus for updating information in a computer system using logs and state identifiers
WO2017122060A1 (fr) * 2016-08-25 2017-07-20 Huawei Technologies India Pvt. Ltd. Récupération parallèle pour bases de données à disque partagé
CN111507720A (zh) * 2020-04-22 2020-08-07 腾讯科技(深圳)有限公司 基于区块链的数据快照方法、装置及计算机可读存储介质
CN112597153A (zh) * 2020-12-09 2021-04-02 杭州趣链科技有限公司 一种基于区块链的数据存储方法、装置及存储介质
CN114780285A (zh) * 2022-02-25 2022-07-22 蚂蚁区块链科技(上海)有限公司 区块链数据恢复方法及装置、电子设备

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117056131A (zh) * 2023-10-11 2023-11-14 腾讯科技(深圳)有限公司 基于区块链网络的数据处理方法及相关设备
CN117056131B (zh) * 2023-10-11 2024-01-26 腾讯科技(深圳)有限公司 基于区块链网络的数据处理方法及相关设备
CN117670330A (zh) * 2024-02-01 2024-03-08 中国信息通信研究院 基于区块链的交易处理方法和装置、电子设备和存储介质

Also Published As

Publication number Publication date
CN114780285A (zh) 2022-07-22

Similar Documents

Publication Publication Date Title
WO2021017421A1 (fr) Procédé et dispositif de récupération de données d'état de chaîne de blocs, et dispositif électronique
WO2021017436A1 (fr) Procédé et appareil de synchronisation de données d'état de chaîne de blocs, et dispositif électronique
WO2021017435A1 (fr) Procédé et appareil de stockage de données d'état de chaîne de blocs, et dispositif électronique
WO2023160077A1 (fr) Procédé et appareil de récupération de données de chaîne de blocs, et dispositif électronique
US20200167345A1 (en) Method and apparatus for storing blockchain state data and electronic device
US10956444B2 (en) Block chain state data synchronization method, apparatus, and electronic device
WO2021017438A1 (fr) Procédé et appareil d'annulation de facture électronique basée sur une chaîne de blocs, et dispositif électronique
WO2020029931A1 (fr) Procédé et système d'interrogation de données, procédé et système de consensus, dispositif et support d'informations
WO2020258853A1 (fr) Procédé et appareil de stockage hiérarchique basé sur une chaîne de blocs, et dispositif électronique
CN111898139B (zh) 数据读写方法及装置、电子设备
CN108804112A (zh) 一种区块链落账处理方法及系统
US20100036861A1 (en) Method and System for Implementing Parallel Transformations of Records
US10761948B1 (en) Method, apparatus, and electronic device for restoring state data of blockchain
US11036720B2 (en) Blockchain-based hierarchical data storage
TWI724570B (zh) 資料結構的讀取及更新方法、裝置、電子設備及儲存媒體
CN109300036A (zh) 区块链网络的分叉回归方法和装置
US11042518B2 (en) Blockchain-based hierarchical data storage
US20200167840A1 (en) Blockchain-based e-bill number application method, apparatus, and electronic device
TW202107373A (zh) 基於區塊鏈的電子票據報銷方法及裝置、電子設備
WO2022077186A1 (fr) Procédé et appareil d'exécution d'un contrat intelligent dans une chaîne de blocs, et dispositif électronique
TW202125296A (zh) 基於區塊鏈的侵權取證方法及裝置、電子設備、儲存媒體
US20210263905A1 (en) Blockchain based hierarchical data storage
WO2023160094A1 (fr) Procédé et appareil de vérification de transaction basée sur une chaîne de blocs, et dispositif électronique
WO2021017432A1 (fr) Procédé et appareil de segmentation de dépenses de remboursement basée sur une chaîne de blocs, et dispositif électronique
CN109325011A (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: 22928337

Country of ref document: EP

Kind code of ref document: A1