CN113886135A - Block chain data recovery method and device - Google Patents

Block chain data recovery method and device Download PDF

Info

Publication number
CN113886135A
CN113886135A CN202110825650.XA CN202110825650A CN113886135A CN 113886135 A CN113886135 A CN 113886135A CN 202110825650 A CN202110825650 A CN 202110825650A CN 113886135 A CN113886135 A CN 113886135A
Authority
CN
China
Prior art keywords
blockchain
transaction
account
data recovery
resources
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110825650.XA
Other languages
Chinese (zh)
Inventor
卓海振
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alipay Hangzhou Information Technology Co Ltd
Original Assignee
Alipay Hangzhou Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alipay Hangzhou Information Technology Co Ltd filed Critical Alipay Hangzhou Information Technology Co Ltd
Priority to CN202110825650.XA priority Critical patent/CN113886135A/en
Publication of CN113886135A publication Critical patent/CN113886135A/en
Pending legal-status Critical Current

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/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
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Abstract

The present specification provides a method and an apparatus for recovering blockchain data, which are applied to a node device of a blockchain, where a system resource carried by the node device and a virtual resource released on the blockchain are subjected to value anchoring, and the method includes: receiving a data recovery transaction sent by a blockchain client, wherein the data recovery transaction comprises identification information of target data to be recovered and an account identification of a user; calculating a first amount of system resources of a node device consumed to process the data recovery transaction and determining a second amount of the virtual resources anchored to the first amount of system resource value; deducting the second amount of virtual resources from the virtual resources held by the user account corresponding to the account identifier; and executing the data recovery transaction after deduction, and recovering the target data to a target intelligent contract account maintained by the user based on the identification information of the target data.

Description

Block chain data recovery method and device
Technical Field
One or more embodiments of the present disclosure relate to the field of blockchain technologies, and in particular, to a method and an apparatus for recovering blockchain data.
Background
The block chain technology, also called distributed ledger technology, is an emerging technology in which several computing devices participate in "accounting" together, and a complete distributed database is maintained together. The blockchain technology has been widely used in many fields due to its characteristics of decentralization, transparency, participation of each computing device in database records, and rapid data synchronization between computing devices.
Disclosure of Invention
In view of this, one or more embodiments of the present specification provide a method, an apparatus, and a computer device for recovering blockchain data.
In order to achieve the above purpose, one or more embodiments of the present specification provide the following technical solutions:
according to a first aspect of one or more embodiments of the present specification, there is provided
A method for recovering block chain data is applied to node equipment of a block chain, wherein system resources carried by the node equipment and virtual resources released on the block chain are subjected to value anchoring, and the method comprises the following steps:
receiving a data recovery transaction sent by a blockchain client, wherein the data recovery transaction comprises identification information of target data to be recovered and an account identification of a user;
calculating a first amount of system resources of a node device consumed to process the data recovery transaction and determining a second amount of the virtual resources anchored to the first amount of system resource value;
deducting the second amount of virtual resources from the virtual resources held by the user account corresponding to the account identifier; and executing the data recovery transaction after deduction, and recovering the target data to a target intelligent contract account maintained by the user based on the identification information of the target data.
According to a second aspect of one or more embodiments of the present specification, there is provided
A method for recovering block chain data is applied to node equipment of a block chain, wherein system resources carried by the node equipment and virtual resources released on the block chain are subjected to value anchoring, and the method comprises the following steps:
receiving a data recovery transaction sent by a blockchain client, wherein the data recovery transaction comprises identification information of target data to be recovered and an account identification of a user;
executing the data recovery transaction, and recovering the target data to a target intelligent contract account maintained by the user based on the identification information of the target data;
after performing the data recovery transaction, calculating a first amount of system resources of a node device consumed to process the data recovery transaction, determining a second amount of the virtual resources that are anchored to the first amount of system resource value; and deducting the second amount of virtual resources from the virtual resources held by the user account corresponding to the account identifier.
According to a third aspect of one or more embodiments of the present specification, there is provided
A device for recovering block chain data is applied to node equipment of a block chain, wherein system resources carried by the node equipment and virtual resources released on the block chain are subjected to value anchoring, and the device comprises:
the receiving unit is used for receiving a data recovery transaction sent by the blockchain client, wherein the data recovery transaction comprises identification information of target data to be recovered and an account identification of a user;
a computing unit to compute a first amount of system resources of a node device consumed to process the data recovery transaction and to determine a second amount of the virtual resources anchored to the first amount of system resource value;
the deduction unit is used for deducting the virtual resources of the second quantity from the virtual resources held by the user account corresponding to the account identification;
and the execution unit executes the data recovery transaction after deduction, and recovers the target data to the target intelligent contract account maintained by the user based on the identification information of the target data.
According to a fourth aspect of one or more embodiments of the present specification, there is provided
A device for recovering block chain data is applied to node equipment of a block chain, wherein system resources carried by the node equipment and virtual resources released on the block chain are subjected to value anchoring, and the device comprises:
the receiving unit is used for receiving a data recovery transaction sent by the blockchain client, wherein the data recovery transaction comprises identification information of target data to be recovered and an account identification of a user;
the execution unit is used for executing the data recovery transaction and recovering the target data to a target intelligent contract account maintained by the user based on the identification information of the target data;
a computing unit that, after executing the data recovery transaction, computes a first amount of system resources of a node device consumed to process the data recovery transaction, and determines a second amount of the virtual resources that are anchored with the first amount of system resource value;
and the deduction unit is used for deducting the virtual resources of the second quantity from the virtual resources held by the user account corresponding to the account identification.
According to a fifth aspect of one or more embodiments of the present specification, there is provided a computer device comprising: a memory and a processor; the memory having stored thereon a computer program executable by the processor; when the computer program is executed by the processor, the method for recovering blockchain data executed by a node device according to the embodiment of the first aspect is performed.
According to a sixth aspect of one or more embodiments of the present specification, there is provided a computer apparatus comprising: a memory and a processor; the memory having stored thereon a computer program executable by the processor; when the computer program is executed by the processor, the method for recovering blockchain data executed by the node device according to the embodiment of the second aspect is executed.
Based on the method, the apparatus, the computer device, and the computer-readable storage medium for recovering blockchain data described in one or more embodiments above, the system resources hosted by the node devices of the blockchain may perform value anchoring with the virtual resources, so that a first amount of system resources of the node devices of the blockchain consumed by the node devices for processing data recovery transactions may be anchored, a second amount of virtual resources may be anchored, and the node devices of the blockchain charge the second amount of virtual resources, so that a user may recover previous data from an account storage space of an intelligent contract to an account storage space of the intelligent contract.
Drawings
FIG. 1 is a schematic diagram of creating an intelligent contract provided by an exemplary embodiment;
FIG. 2 is a schematic diagram of a calling smart contract provided by an exemplary embodiment;
FIG. 3 is a schematic diagram of creating an intelligent contract and invoking an intelligent contract provided by an exemplary embodiment;
FIG. 4 is a flowchart illustrating a method for recovering blockchain data according to an exemplary embodiment;
fig. 5 is a schematic diagram of a device for recovering blockchain data applied to a node device side of a blockchain according to an exemplary embodiment;
fig. 6 is a schematic diagram of a device for recovering blockchain data applied to a node device side of a blockchain according to yet another exemplary embodiment;
fig. 7 is a hardware configuration diagram of an embodiment of a recovery apparatus for performing blockchain data provided in the present specification.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with one or more embodiments of the present specification.
It should be noted that: in other embodiments, the steps of the corresponding methods are not necessarily performed in the order shown and described herein. In some other embodiments, the methods may include more or less steps than those described herein. Moreover, a single step described in this specification may be divided into multiple steps for description in other embodiments; however, in other embodiments, multiple steps described in this specification may be combined into a single step for description.
The block chain or block chain network described in one or more embodiments of the present specification may specifically refer to a P2P network system having a distributed data storage structure, where each node device achieves through a common recognition mechanism, the book data in the block chain is distributed within temporally consecutive "blocks", and the latter block may include a data digest of the former block, and according to a difference of a specific common recognition mechanism (such as POW, POS, DPOS, PBFT, or the like), a full backup of data of all or part of nodes is achieved.
Blockchains are generally divided into three types: public chain (Public Blockchain), Private chain (Private Blockchain) and alliance chain (Consortium Blockchain). Furthermore, there may be a combination of the above types, such as private chain + federation chain, federation chain + public chain, and so on.
Among them, the most decentralized is the public chain. Participants joining the public chain (also referred to as nodes in the blockchain) can read the data records on the chain, participate in transactions, compete for accounting rights for new blocks, and so on. Moreover, each node can freely join or leave the network and perform related operations.
Private chains are the opposite, with the network's write rights controlled by an organization or organization and the data read rights specified by the organization. Briefly, a private chain may be a weakly centralized system with strict restrictions on nodes and a small number of nodes. This type of blockchain is more suitable for use within a particular establishment.
A federation chain is a block chain between a public chain and a private chain, and "partial decentralization" can be achieved. Each node in a federation chain typically has a physical organization or organization corresponding to it; the nodes are authorized to join the network and form a benefit-related alliance, and block chain operation is maintained together.
The computing device may construct the data into a standard transaction (transaction) format supported by the blockchain, then issue the transaction to the blockchain, perform consensus processing on the received transaction by the node devices in the blockchain, and package the transaction into a block by the node devices serving as accounting nodes in the blockchain after the consensus is achieved, and perform persistent evidence storage in the blockchain.
Regardless of which consensus algorithm is adopted by the block chain, the accounting node can pack the received transaction to generate a latest block and send the latest block to other node devices for consensus verification. If the latest block is received by other node equipment and no problem is proved, the latest block can be added to the tail of the original block chain, so that the accounting process of the block chain is completed. The transactions contained in the block may also be performed during the process of the other nodes verifying the new block sent by the accounting node.
It should be noted that, each time a latest block is generated in the blockchain, the corresponding status of the executed transactions in the blockchain changes after the transaction in the latest block is executed. For example, in a block chain constructed by an account model, the account status of an external account or a smart contract account usually changes correspondingly with the execution of a transaction.
For example, when a "transfer transaction" is completed in a block, the balances of the transferring party account and the transferring party account associated with the "transfer transaction" (i.e., the field values of the Balance fields of these accounts) are usually changed.
For another example, the "intelligent contract invocation transaction" in the block is used to invoke an intelligent contract deployed on the blockchain, invoke the intelligent contract in the EVM corresponding to the node device to execute the "intelligent contract invocation transaction", and update the account status of the intelligent contract account in the account of the intelligent contract after the execution of the intelligent contract invocation transaction.
In practical applications, whether public, private, or alliance, it is possible to provide the functionality of a Smart contract (Smart contract). An intelligent contract on a blockchain is a contract on a blockchain that can be executed triggered by a transaction. An intelligent contract may be defined in the form of code.
The support user creates and invokes some complex logic in the blockchain network. At the heart of the programmable blockchain is a virtual machine (EVM), each blockchain node can run the EVM. The EVM is a well-behaved virtual machine through which various complex logic can be implemented. The user issuing and invoking the intelligent contracts in the blockchain is running on the EVM. In fact, the EVM directly runs virtual machine code (virtual machine bytecode, hereinafter referred to as "bytecode"), so the intelligent contract deployed on the blockchain may be bytecode.
After Bob sends a Transaction (Transaction) containing information to create a smart contract to the blockchain network, each node can execute the Transaction in the EVM, as shown in fig. 1. The From field of the transaction in the figure is used for recording the address of the account initiating the creation of the intelligent contract, the contract code stored in the field value of the Data field of the transaction can be byte code, and the field value of the To field of the transaction is a null account. After the nodes reach the agreement through the consensus mechanism, the intelligent contract is successfully created, and the follow-up user can call the intelligent contract.
After the intelligent contract is established, a contract account corresponding to the intelligent contract appears on the block chain, and the block chain has a specific address; for example, "0 x68e12cf284 …" in each node in fig. 1 represents the address of the contract account created; the contract Code (Code) and account store (Storage) will be maintained in the account store for that contract account. The behavior of the intelligent contract is controlled by the contract code, while the account storage of the intelligent contract preserves the state of the contract. In other words, the intelligent contract causes a virtual account to be generated on the blockchain that contains the contract code and account storage.
As mentioned above, the Data field containing the transaction that created the intelligent contract may hold the byte code of the intelligent contract. A bytecode consists of a series of bytes, each of which can identify an operation. Based on the multiple considerations of development efficiency, readability and the like, a developer can select a high-level language to write intelligent contract codes instead of directly writing byte codes. For example, the high-level language may employ a language such as Solidity, Serpent, LLL, and the like. For intelligent contract code written in a high-level language, the intelligent contract code can be compiled by a compiler to generate byte codes which can be deployed on a blockchain.
Taking the Solidity language as an example, the contract code written by it is very similar to a Class (Class) in the object-oriented programming language, and various members including state variables, functions, function modifiers, events, etc. can be declared in one contract. A state variable is a value permanently stored in an account Storage (Storage) field of an intelligent contract to save the state of the contract.
As shown in fig. 2, after Bob sends a transaction containing the information of the invoked smart contract to the blockchain network, each node may execute the transaction in the EVM. The From field of the transaction in the figure is used for recording the address of the account initiating the intelligent contract calling, the To field is used for recording the address of the intelligent contract called, and the Data field of the transaction is used for recording the method and the parameters for calling the intelligent contract. After invoking the smart contract, the account status of the contract account may change. Subsequently, a client may check the account status of the contract account through the accessed block link points, for example, the account status may be stored in the Storage tree of the intelligent contract in the form of a Key-Value pair. The results of the execution of the transaction that invokes the smart contract, which may be in the form of a transaction receipt (receipt), are stored in the MPT receipt tree.
The intelligent contract can be independently executed at each node in the blockchain network in a specified mode, and all execution records and data are stored on the blockchain, so that after the transaction is executed, transaction certificates which cannot be tampered and lost are stored on the blockchain.
A schematic diagram of creating an intelligent contract and invoking the intelligent contract is shown in fig. 3. An intelligent contract is created in the block chain, and the intelligent contract needs to be written, changed into byte codes, deployed to the block chain and the like. The intelligent contract is called in the block chain, a transaction pointing to the intelligent contract address is initiated, the EVM of each node can respectively execute the transaction, and the intelligent contract code is operated in a distributed mode in the virtual machine of each node in the block chain network.
For accounts in a blockchain, the account status of the account is usually maintained through a structure. When a transaction in a block is executed, the status of the account associated with the transaction in the block chain is also typically changed.
The structure of an account typically includes fields such as Balance, Nonce, Code, and Storage. Wherein:
a Balance field for maintaining the current account Balance of the account;
a Nonce field for maintaining a number of transactions for the account; the counter is used for guaranteeing that each transaction can be processed only once, and replay attack is effectively avoided;
a Code field for maintaining a contract Code for the account; in practical applications, only the hash value of the contract Code is typically maintained in the Code field; thus, the Code field is also commonly referred to as the Codhash field.
A Storage field for maintaining the Storage contents of the account (default field value is null); for a contract account, a separate storage space is usually allocated to store the storage content of the contract account; this separate storage space is often referred to as the account storage of the contract account. The storage content of the contract account is usually constructed into a data structure of an MPT (Merkle Patricia Trie) tree and stored in the independent storage space; in which, the Storage content based on the contract account is constructed into an MPT tree, which is also commonly referred to as a Storage tree. Whereas the Storage field typically maintains only the root node of the Storage tree; thus, the Storage field is also commonly referred to as the Storage root field.
Wherein, for the external account, the field values of the Code field and the Storage field shown above are both null values.
For most blockchain models, Merkle trees are typically used; alternatively, the data is stored and maintained based on the data structure of the Merkle tree. For example, an MPT tree (a Merkle tree variety) is used as a data organization form for organizing and managing important data such as account status, transaction information, and the like.
Three MPT trees are designed aiming at data needing to be stored and maintained in a block chain, namely an MPT state tree, an MPT transaction tree and an MPT receipt tree. In addition to the three MPT trees, there is actually a Storage tree constructed based on the Storage content of the contract account.
An MPT state tree, which is an MPT tree organized by account state data of all accounts in a blockchain; an MPT transaction tree, which is an MPT tree organized by transaction (transaction) data in a blockchain; the MPT receipt tree is organized into transaction (receipt) receipts corresponding to each transaction generated after the transactions in the block are executed. The hash values of the root nodes of the MPT state tree, the MPT transaction tree, and the MPT receipt tree shown above are eventually added to the block header of the corresponding block.
The MPT transaction tree and the MPT receipt tree correspond to the blocks, namely each block has the MPT transaction tree and the MPT receipt tree. For the MPT transaction tree, the MPT receipt tree and the MPT state tree which are organized, the MPT transaction tree, the MPT receipt tree and the MPT state tree are finally stored in a Key-Value type database (such as a levelDB) which adopts a multi-level data storage structure.
In the public chain field, the miners are often encouraged to carry out block chaining out through gas, token and other modes, and the miners can select higher-commission-cost transactions such as gas or token to preferentially pack in blocks so as to increase self income; for the non-miner nodes, although the storage and consensus resources are contributed, corresponding benefits are not obtained. In a token-free (token) -based blockchain model, such as a federation chain, especially in an open federation chain environment, how to count blockchain resources provided by node devices and cover corresponding node costs is also an urgent issue to be solved. At present, there is no method for resource management and charging for users of the blockchain based on the use or occupation of blockchain resources.
In view of the above, one or more embodiments of the present specification provide various resource charging approaches in a blockchain system. It is contemplated that the embodiments provided herein can be implemented in a suitable type of blockchain network, such as a public chain, a federation chain, a private chain, and so forth.
The client in one or more embodiments provided in this specification may be an independent device communicatively connected to any node device of the blockchain, or may be a functional module disposed inside any node device, which is not limited herein.
In the charging mode of the blockchain system provided in the present specification, the system resources installed on the node devices of the blockchain are value-anchored to the virtual resources distributed on the blockchain.
The virtual resources published on the blockchain may include blockchain assets having a value anchoring relationship with off-chain real assets held by the user, and virtual resources anchored with the frozen real assets and capable of circulating on the chain may be published on the chain by freezing real-world real assets (including assets in the form of money, real estate, stocks, loan contracts, bills, accounts receivable, and the like).
When the method is realized, a user client can execute an asset freezing exchange process with node equipment of a block chain network, and the user client sends a certain amount of freezing vouchers of real assets to the node equipment corresponding to an organization with virtual resource exchange authority; the node device can broadcast the frozen voucher to the blockchain network after receiving the frozen voucher, so that the node device in the blockchain can add virtual resources corresponding to the frozen real asset amount value to the account balance of the blockchain of the user based on the frozen voucher.
The virtual resource corresponding to the frozen real asset amount value is added into the balance of the user's blockchain account based on the frozen certificate, and the method can be further realized by the interaction between the user and an intelligent contract: the user client or the node equipment corresponding to the mechanism with the virtual resource exchange authority sends a virtual resource exchange transaction to the blockchain network, wherein the virtual resource exchange transaction comprises the asset freezing voucher; responding to the virtual resource exchange transaction, the node equipment of the blockchain calls a virtual resource exchange contract deployed on the blockchain, executes the resource exchange logic declared by the intelligent contract, and adds virtual resources corresponding to the real asset amount value frozen by the asset freezing voucher into the account balance of the blockchain of the user.
Based on the mode, the user can obtain virtual resources which can be anchored with the value of the real assets in the block chain network based on the real assets held by the user, and the virtual resources can be expressed as the balance of the account on the chain of the user.
In the blockchain network system, the system resources provided by the blockchain node devices for the blockchain service can be value-anchored with the virtual resources published on the blockchain. For example, the storage resources provided by the node device for the data on the blockchain may perform value anchoring with the virtual resources published on the blockchain, and the blockchain data per unit capacity of storage may obtain the virtual resources corresponding thereto; for another example, the CPU computational resources provided by the node device for executing any transaction on the blockchain may be value-anchored with the virtual resources issued on the blockchain, and the virtual resources corresponding to the CPU computational resources may be acquired for each unit number of CPU instruction sets executed; for another example, the network resource provided by the node device for broadcast and consensus of any transaction on the blockchain may perform value anchoring with the virtual resource published on the blockchain, and may obtain the corresponding virtual resource based on the network traffic consumed in the broadcast or consensus process of the uplink transaction.
The block chain developer may quantify the system resources in the form of the storage resources, the computing resources, the network resources, and the like, and price the number of virtual resources corresponding to each unit of the storage resources, the computing resources, the network resources, or the system resources in other forms in the block chain network. For a federation chain, whose federation members are relatively fixed, the system resource pricing resulting from the anchoring can remain fixed for a longer period of time; for a public link system, nodes enter or exit a blockchain network more frequently, and after a blockchain developer performs unit pricing on the system resources in various forms, the blockchain developer performs real-time charging based on the blockchain scale when a user uses the blockchain or performs periodic charging according to a shorter period. Those skilled in the art can also charge the user for the blockchain service provided by the blockchain endpoint device based on any form of system resource having a value anchor relationship with the virtual resource published on the blockchain from the actual cost requirement, which is not limited in the present specification.
As shown in fig. 4, a method for recovering blockchain data provided in an exemplary embodiment of the present specification includes:
step 402, a node device of the blockchain receives a data recovery transaction sent by a blockchain client, where the data recovery transaction includes identification information of target data to be recovered and an account identification of a user.
The target data to be recovered is originally target data stored in a target intelligent contract account maintained by a user, for example, target data stored in an account storage space of a target intelligent contract; the target data may then be deleted from the target intelligent contract account based on a delete operation of the user maintaining the managed target intelligent contract. Or when the effective duration of the storage resource allocated to the target intelligent contract account by the node device of the user request block chain is expired, deleting the target data in the target intelligent contract account by a system administrator and other users with high-level system management authority by issuing a data deletion instruction. The data of the account storage space of the intelligent contract may be stored in a Key-Value format, and the identification information of the target data may include a Key Value of the target data, such as a hash Value of the target data, and the target data may be uniquely determined on the block chain based on the hash Value of the target data.
Optionally, the data recovery transaction may further include identification information such as an account address of a target intelligent contract in which the target data to be recovered is located. At this time, the identification information of the target data may further include other identifications, such as a serial number of data stored in the account storage space of the target smart contract, and the like.
The user account corresponding to the account identifier is a blockchain user account of virtual resources anchored with the blockchain system resources, which is deducted based on the blockchain system resources consumed by processing the data recovery transaction; the user account corresponding to the account identifier may include the user account of the data recovery transaction publisher, or may include other user accounts designated by the data recovery transaction publisher, for example, an account of a target intelligent contract maintained by the data recovery transaction publisher; the account type of the user account may include an external account, or may include an intelligent contract account, which is not limited in this embodiment.
Step 404, calculating a first amount of system resources of the node device consumed for processing the data recovery transaction, and determining a second amount of the virtual resources anchored to the first amount of system resource value.
The process of processing the data recovery transaction by the node device of the blockchain may include one or more of receiving, forwarding (broadcasting) the data recovery transaction, performing consensus verification on the data recovery transaction, performing the data recovery transaction based on the identification information of the target data to recover and store the target data to an account storage space of a target intelligent contract maintained by the user, and including the data recovery transaction in a new block. Because the value of the system resources carried by the node devices is anchored with the virtual resources published on the blockchain, and the node devices of the blockchain provide their own system resources in the overall process of processing the data recovery transaction, the node devices of the blockchain can calculate and determine a second amount of virtual resources anchored with the value of the first amount of system resources based on the first amount of system resources consumed or provided by the node devices in the process of processing the data recovery transaction.
In particular, the system resources of the node device consumed by processing the data recovery transaction described above may include a combination of one or more of the following:
processing computational resources of the node device consumed by the data recovery transaction, which may include a number of instructions in a CPU instruction set consumed by the node device to perform the data recovery transaction based on the identification information of the target data. For example, the blockchain system may price the computing resources provided by the node devices: m (virtual resource units)/instruction, the node device may first calculate the number N of instructions in the CPU instruction set consumed to perform the data recovery transaction, and then calculate the number of virtual resources corresponding to the N instructions, anchored to the value of the computational resources of the node device consumed to process the data recovery transaction: m N (virtual resource units).
Processing network resources of the node device consumed by the data recovery transaction, where the network resources may include network traffic of a blockchain consumed in transmitting the data recovery transaction in broadcasting, consensus, or the like, and the network resources are positively correlated with the number of nodes of the blockchain. For example, the blockchain system may price network resources provided by the node devices: m (virtual resource units)/megaflow, the node device may first calculate a total network flow N megameters consumed to perform the data recovery transaction, and then calculate a number of virtual resources corresponding to the N megaflows, anchored to a network resource value of the node device consumed to process the data recovery transaction: m N (virtual resource units).
And processing the data to recover the storage resources of the node equipment consumed by the transaction, wherein the storage resources can comprise the storage resources of the node equipment occupied by the target data in the target intelligent contract account.
The blockchain system may price the storage resources provided by the node device for the target intelligent contract account: m (virtual resource units)/Gb, when the capacity of the target data is NGb, the node device may calculate the amount of virtual resources anchored to the value of the storage resources of the node device consumed for processing the data recovery transaction, including: m N (virtual resource units).
In order to customize the specific duration of time that a node device may provide storage resources for target data based on the needs of a user, in yet another illustrated embodiment, the data recovery transaction further comprises: the effective duration of the target data stored in the target intelligent contract account is requested by the user; the effective duration of the storage resources carried by the node equipment is also subjected to value anchoring with the virtual resources issued on the block chain; accordingly, the calculating the number of virtual resources anchored to the storage resource value provided by the node device includes: and calculating the amount of the storage resources consuming the target intelligent contract account and the virtual resources anchored by the effective duration value with the target data.
For example, the blockchain system may price the storage resources and storage validity periods provided by the node devices to store the target intelligent contract account: m (virtual resource unit)/Gb/day, the user has requested a valid duration of one year for the target data in the data recovery transaction, and when the capacity of the target data is NGb, the node device may calculate the amount of virtual resources anchored to the storage resource value of the node device consumed for processing the smart contract creation transaction, including: m × N × 365 (virtual resource unit).
It is noted that the data recovery transaction may include a field corresponding to a validity duration of the user request to store the target data in the target intelligent contract account being null, so as to perform the calculation of the second amount of the virtual resource by the node device based on the validity duration of the blockchain system default.
The pricing of system resources provided by node devices by the blockchain system described above may be related to the number of nodes of the blockchain system, and it is expected that the more node devices of the blockchain, the more the total amount of system resources actually consumed to perform the data deletion transaction, and thus, the blockchain system may adjust the pricing per unit of system resources charged to the user based on the number of node devices.
In this embodiment, the form of the system resource is not specifically limited, and besides the computing resource, the network resource, or the storage resource, a block chain system developer may anchor the value of the system resource in the form and the virtual resource issued on the block chain based on other forms of system resources of block chain link point devices consumed in the process of recovering target data stored in the smart contract, so as to transfer a corresponding amount of virtual resources from the user account based on the form of system resource consumption.
In an illustrated embodiment, a computation model may be deployed in the underlying protocol of the blockchain, and is used to compute the number of virtual resources anchored to the system resource value of the node device consumed for processing the data recovery transaction, and when the node device receives the data recovery transaction sent by the blockchain client, the node device may obtain a second number of virtual resources corresponding to the system resources consumed for processing the data recovery transaction, where the second number is computed by the computation model deployed in the underlying protocol of the blockchain.
Or, an intelligent contract (hereinafter referred to as a resource computation contract) for computing virtual resource consumption for the data recovery transaction may be further deployed on the blockchain, where the execution logic corresponding to the contract code of the resource computation contract includes resource computation logic for computing the amount of virtual resources anchored to the system resources of the node device consumed for processing the data recovery transaction;
accordingly, calculating a first amount of system resources of the node device consumed by processing the data recovery transaction and determining a second amount of the virtual resources anchored to the first amount of system resource value includes:
invoking the resource calculation contract, executing the billing logic, calculating a first amount of system resources of a node device consumed to execute the data recovery transaction, and determining a second amount of the virtual resources anchored to the first amount of system resource value.
It should be noted that, when the node device invokes the resource computation intelligent contract, a Local Transaction (Local Transaction or Local call) may be constructed in response to the obtained intelligent contract creation Transaction, and the resource computation intelligent contract deployed on the blockchain is locally invoked by the node device to determine the second quantity of the virtual resource anchored by the system resource value of the node device consumed for executing the intelligent contract creation Transaction. At this time, the node device may obtain the call execution result of the resource computation contract locally without recognizing the call execution result of the resource computation contract on the blockchain.
Step 406, deducting the second amount of virtual resources from the virtual resources held by the user account corresponding to the account identifier.
After deduction is completed, the second amount of virtual resources may be allocated to the blockchain account corresponding to the node device of the blockchain for holding. The deducted second amount of virtual resources may be directly allocated by the node device to the blockchain account corresponding to each node device in the blockchain that handles the smart contract creation transaction, so as to directly complete the allocation of the virtual resources.
Alternatively, the node device may first allocate the deducted second amount of virtual resources to a block chain account set on a block chain, such as a block chain account corresponding to each round of accounting nodes of the block chain, or a preset block chain account having the virtual resource receiving authority, so as to create system resources of the block chain consumed by the transaction based on processing the intelligent contract, and receive the second amount of virtual resources on behalf of each node device in the block chain.
After that, the blockchain can also set a corresponding virtual resource allocation rule, and the virtual resource obtained based on creating the intelligent contract is allocated to other blockchain user accounts by the set blockchain account based on a preset period (including real-time or periodically); or responding to the cashing requests of other blockchain users, exchanging the virtual resources which are to be distributed to other blockchain users into entity assets outside the chain, and performing logout processing on the virtual resources on the chain after the virtual resources are exchanged.
The rule for allocating the second amount of virtual resources to the blockchain account corresponding to each node device in the blockchain is not specifically limited in this specification. For example, the node device may equally allocate the deducted second amount of virtual resources to the blockchain accounts corresponding to the node devices of the blockchain to hold the deducted second amount of virtual resources.
Or, based on the storage medium performance attribute of the account storage resource allocated to the intelligent contract by each node device of the blockchain, allocating the second number of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier to the blockchain accounts corresponding to each node device of the blockchain to hold the virtual resources respectively. For example, since the storage media configurations of the node devices are different, the blockchain system may rank the storage media of each node device based on the obtained storage media performance attribute (e.g., hard disk performance attribute such as hdd, ssd, or nvm) of each node device, so as to allocate a higher proportion of virtual resources to the node device providing a high-level storage media and allocate a lower proportion of virtual resources to the node device providing a low-level storage media.
And 408, executing the data recovery transaction, and recovering the target data to the target intelligent contract maintained by the user based on the identification information of the target data. For example, the target data is restored to a target smart contract account maintained by the user.
The users who maintain the target intelligent contract may include the creating user of the target intelligent contract or the users who have data recovery authority stated in the target intelligent contract.
The target data described in the embodiments of the present specification is originally stored in a target intelligent contract account (for example, an account storage space of a target intelligent contract), and may be later deleted from the target intelligent contract by a user who maintains the target intelligent contract by issuing a data deletion transaction or by issuing a data deletion instruction by a blockchain system, for the purpose of optimizing the storage of the target intelligent contract account. Because the data stored in the intelligent contract account may be basic data for executing the intelligent contract invoking transaction, after the target data is deleted, the subsequent intelligent contract invoking transaction may not be executed correctly; therefore, after the target data is deleted, the user may request the blockchain system to restore the previously deleted target data in order to solve the problem that the intelligent contract invoking transaction cannot be executed correctly, or the user may request the blockchain system to restore the previously deleted target data according to the user's own needs.
In an illustrated embodiment, the aforementioned deleting the target data from the target intelligent contract account maintained by the user may include deleting the target data directly from the target intelligent contract account. At this time, the restoring, performed by the node device, the target data to the target intelligent contract account maintained by the user based on the identification information of the target data includes:
re-executing the transactions associated with the target intelligent contract that are included in the blockchain until the target data determined based on the identification information of the target data is restored to the target intelligent contract account.
Since re-executing the transaction associated with the target intelligent contract may consume a large amount of system resources, and the client may need a long waiting time to receive the notification message that the target data is recovered, in order to obtain the target data more quickly, the node device may further provide the client with a plurality of state snapshots (check points) about the target intelligent contract, so that the user selects a state snapshot as a starting point for starting re-executing the transaction associated with the target intelligent contract.
In yet another illustrative embodiment, the deleting the target data from the target intelligent contract account maintained by the user may include removing the target data from the target intelligent contract account and storing the target data in a backup database maintained by the blockchain, for example, a "cold data" database in the blockchain.
The cold data in the blockchain comprises non-real-time data which is set by a blockchain system and cannot be directly called by an intelligent contract, such as transactions in a historical block, historical state data corresponding to the historical block and the like; to save storage costs, the cold data may be stored in less performance configured storage hardware. In contrast, the hot data in the blockchain may include data (also referred to as real-time data) required by the intelligent contract invocation, such as data included in the intelligent contract account, data in the latest blocks required by the intelligent contract invocation, index data of the blockchain, and the like, and the hot data of the blockchain is usually stored by the node device in storage hardware with superior performance, such as an SSD hard disk, so that the node device can efficiently and quickly perform the intelligent contract invocation transaction.
Therefore, in this embodiment, the account storage space may store "hot data" that needs to be used for the intelligent contract invocation, and the target data of the hot data may be moved by the node device to the database collecting "cold data" of the blockchain for the purpose of saving the storage space of the target intelligent contract. In the subsequent block chaining blocking process, the node device executes a data recovery transaction sent by the user, and can query the target data in the cold database based on the identification information of the target data and migrate and recover the target data to the account storage space of the target intelligent contract.
Compared with the implementation mode of directly deleting the target data and re-executing the target data through the block transaction, the deletion and recovery mode of the target data saves the process of re-identifying, verifying and executing a plurality of transactions by the node device, has less system resource consumption and belongs to a better implementation mode.
Based on the method for recovering blockchain data described in steps 402 to 408, a transaction of a development data recovery type (for example, a transaction type executable by a system developer on an extended blockchain in a bottom layer protocol, a transaction of an extended development data deletion type and a transaction of a data recovery type except for a transfer transaction, an intelligent contract creation transaction and an intelligent contract call transaction) may be configured in a blockchain system, initiated by a user who maintains and manages a target intelligent contract, and the deleted target data in the account storage space of the target intelligent contract is recovered to the account storage space of the target intelligent contract; because the data storage resources allocated by the blockchain node device for the intelligent contract account are usually high-quality storage resources, such as SSD hot storage resources, so as to quickly and efficiently perform the call execution of the intelligent contract, the block chain data recovery method according to the embodiment can further optimize the processing performance of the intelligent contract call transaction in the blockchain, and improve the probability of correct execution of the intelligent contract call transaction.
In order to facilitate management of storage resources allocated to the target intelligent contract account by the node device by a user, the remaining storage capacity of the storage resources allocated to the target intelligent contract account by the node device may be maintained in the block chain.
For example, the node device may maintain, in the target intelligent contract account, a remaining storage capacity of the storage resources provided by the node device for the target intelligent contract account. In specific implementation, a content field (except Balance, Nonce, Code, and Storage) supported by the target intelligent contract account may be extended to increase a remaining Storage capacity parameter for identifying a node device of the block chain to provide Storage resources for the target intelligent contract account.
Or, the blockchain may also perform maintenance management on the remaining storage capacity of the storage resource corresponding to the target intelligent contract account in a bottom layer protocol of the system, and each node device may obtain the state of the remaining storage capacity of the storage resource corresponding to the target intelligent contract account when viewing the attribute of the target intelligent contract account.
As another example, the above blockchain may also deploy a special management contract for managing, in the management contract account, the remaining storage capacity of the storage resource allocated by the maintenance node device for the target intelligent contract account, and so on.
Therefore, after performing the data recovery transaction according to one or more of the above embodiments, the method may further include updating the remaining storage capacity of the storage resource allocated to the target intelligent contract account by the node device maintained by the blockchain after the target data is recovered: for example, a value of remaining storage capacity of storage resources allocated for the target intelligent contract account maintained in the blockchain is reduced based on the target data being restored.
The value of the storage resource capacity maintained in the blockchain may be specified by a create transaction of the target intelligent contract at the time of creation of the target intelligent contract. Or, in the life of the target intelligent contract, the user may correspondingly extend or reduce the storage resource capacity provided by the node device for the target intelligent contract according to the actual demand, so as to change the storage resource capacity state maintained in the target intelligent contract account. During the creation or the existence period of the target intelligent contract, the node device may allocate, to the target intelligent contract, a storage resource with a set storage capacity requested by the user based on deduction of the virtual resource from the user account, and by the data recovery method according to one or more embodiments, the user may optimally manage the account storage of the target intelligent contract and recover important data.
In one or more of the above embodiments, the sequence of steps 404, 406 and 408 described in fig. 4 is not limited. In an illustrative embodiment, a node device may first perform steps 404 and 406 to calculate a first amount of system resources of the node device to consume for processing the data recovery transaction based on the data recovery transaction and determine a second amount of the virtual resources anchored to the first amount of system resource value; after the virtual resources held by the user account corresponding to the account identifier are successfully executed and the second amount of virtual resources are deducted, the node device further executes step 408 to execute the data recovery transaction and recover the target data to the target intelligent contract account maintained by the user.
The node device may then return a prompt to the blockchain client indicating completion of execution of the data recovery transaction based on a result of execution of the data recovery transaction (e.g., a transaction receipt corresponding to the data recovery transaction as included in an MPT receipt tree included in a state database of the blockchain).
In step 406, if the amount of the virtual resources held by the user account is less than the second amount, the node device cannot complete deducting the second amount of the virtual resources, and at this time, the data recovery transaction may not be executed, and a prompt indicating that the execution of the data recovery transaction fails is returned to the blockchain client.
It should be noted that, because the system resources consumed by the node device to execute the data recovery transaction include various forms such as computing resources, network resources, storage resources, and the like, some resource forms may be calculated based on the code of the intelligent contract before the data recovery transaction is executed, and some resource forms may be accurately known only after the data recovery transaction is executed. Thus, in this embodiment, the deducted second amount of virtual resources is derived based on the system resource forecast that may need to be consumed to execute the data recovery transaction in step 406; the block chain may also set a subsequent system resource consumption verification link to check whether the system resources consumed after the target data is recovered obviously do not conform to the estimated system resources, so as to perform corresponding virtual resource supplementation or withdrawal operations, which is not limited in this specification.
In yet another illustrated embodiment, the node device may first execute step 408, execute the data recovery transaction, recover the target data acquired based on the identification information of the target data into the target intelligent contract account, and temporarily store the account status of the recovered target intelligent contract in the memory, at this time, the node device may generate a transaction receipt (receive) based on the execution result of the data recovery transaction, and temporarily store the transaction receipt in the memory; steps 404 and 406 are executed next, calculating a first amount of system resources of the node device consumed for processing the data recovery transaction based on the data recovery transaction, and determining a second amount of the virtual resources anchored to the first amount of system resource value; thereby deducting the second amount of virtual resources from the virtual resources held by the user account corresponding to the account identification.
If the second amount of virtual resources are successfully deducted from the virtual resources held by the user account, the node device can update the account state of the target intelligent contract, and store a transaction receipt (receive) which is generated after the data recovery transaction is executed and represents that the data recovery transaction is successfully executed in an MPT receipt tree of a block chain, so that a prompt of completion of execution of the data recovery transaction can be returned to the block chain client;
if the amount of the virtual resources held by the user account is smaller than the second amount, the node device cannot deduct the second amount of the virtual resources, and at this time, a transaction receipt (receive) containing the successful execution of the data recovery transaction and an account state of a target intelligent contract containing target data, which are generated after the data recovery transaction is executed, may be deleted from a memory, and a prompt indicating that the data recovery transaction is failed to be executed is returned to the blockchain client.
Or, when the amount of the virtual resources held by the user account is smaller than the second amount, and the node device cannot complete the transfer of the second amount of the virtual resources to the blockchain account of the node device, the node device may temporarily store the transaction receipt, and send a balance supplement reminder to the blockchain client, after the blockchain client completes the balance supplement to the user account, execute the second amount of virtual resource transfer operation, and after the transfer is successful, update the account storage space state of the target intelligent contract, store the transaction receipt (receive) in the MPT receipt tree of the blockchain, and return a prompt of completion of the data recovery transaction execution to the blockchain client.
In another illustrative embodiment, the broadcasting, consensus verification, and execution of the data recovery transaction in the blockchain may specifically include:
after receiving the data recovery transaction sent by the blockchain client, the node equipment can broadcast and transmit the data recovery transaction in a blockchain network;
after receiving the data recovery transaction, the consensus node in the block chain can perform consensus verification on the data recovery transaction;
if the consensus verification for the data recovery transaction passes, the node device of the blockchain may add the data recovery transaction to the ledger database of the blockchain and execute the data recovery transaction, calculate and process a second amount of virtual resources anchored by the data recovery transaction value as described in steps 404 to 408, deduct the second amount of virtual resources from the virtual resources held by the user account corresponding to the account identifier, and recover the target data to a target intelligent contract account maintained by the user based on the identification information of the target data.
In this embodiment, in order to reduce the system resource waste of the node device caused by the failure of executing the data recovery transaction due to insufficient balance of the virtual resource in the user account being enough to transfer the second amount of the virtual resource required to be transferred to process the data recovery transaction, the consensus verification process executed by the consensus node of the block chain may include: verifying whether the number of virtual resources held by the user account included in the data recovery transaction is not less than a preset threshold.
The preset threshold may be a fixed virtual resource threshold set by the blockchain developer for the transaction of the data recovery type, for example, the preset threshold may be set based on the minimum system resource consumption for executing the transaction of the data recovery type or the number of virtual resources anchored by the average system resource consumption; under the condition, in order to enable the target data to be successfully recovered, the user account needs to have the virtual resource quantity meeting the preset threshold, so that when the virtual resource quantity in the user account is less than the preset threshold, a prompt that the consensus verification fails is directly returned, and further system resources are prevented from being consumed by processing the data recovery transaction after the node equipment is in the consensus verification stage.
In some embodiments, although the process of processing the data recovery transaction by the node device passes the consensus verification that the balance of the user account is not less than the fixed preset threshold, the transaction may still be executed unsuccessfully due to the fact that the system resources consumed by the data recovery transaction are too large (for example, the storage resources occupied by the target data to be recovered are too large), and the second amount of the virtual resources determined by the calculation is larger than the balance of the user account.
Optionally, the process of calculating the first amount of the system resources of the node device consumed by processing the data recovery transaction and determining the second amount of the virtual resources anchored to the system resource value of the first amount in the process of identifying and verifying the block chain together may be included in the process of identifying and verifying the block chain together, for example, when the underlying protocol of the block chain deploys a calculation model for calculating the amount of the virtual resources anchored to the system resource value of the node device consumed by processing the data recovery transaction, and when the identifying and verifying node acquires the data recovery transaction, the second amount of the system resources anchored to the system resources of the node device consumed by processing the data recovery transaction and determined by the underlying protocol of the block chain may be acquired, and in this case, the preset threshold may be the second amount of the virtual resources determined by the calculation process, therefore, in the consensus verification, the consensus node of the block chain directly executes the consensus verification whether the payment is enough or not based on the second amount of the virtual resources required to be delivered for processing the data recovery transaction, so as to provide more accurate consensus verification, and then, the execution success rate of the data recovery transaction passing the consensus verification can be improved no matter the virtual resource transfer process of the step 406 or the target data recovery process of the step 408 is executed first.
Based on the method for recovering blockchain data according to one or more embodiments, the system resources hosted by the node device of the blockchain and the virtual resources published on the blockchain may be value-anchored, so that a second amount of virtual resources may be anchored based on a first amount of system resources of the node device consumed by the node device for processing data recovery transactions, so as to transfer the second amount of virtual resources from the virtual resources held by the user account to the blockchain account of the node device. The block chain system resource waste caused by random data recovery of the user in the non-charging mode is avoided, and the resource allocation of the block chain is optimized; and the target data is restored to the account storage space of the target intelligent contract, so that the successful execution probability of the target intelligent contract calling transaction on the block chain can be further improved.
Corresponding to the above flow implementation, the embodiments of the present specification further provide recovery apparatuses 50 and 60 for blockchain data. The means 50, 60 may be implemented by software, by hardware or by a combination of both. Taking a software implementation as an example, the logical device is formed by reading a corresponding computer program instruction into a memory for running through a Central Processing Unit (CPU) of the device. In terms of hardware, the device in which the apparatus is located generally includes other hardware such as a chip for transmitting and receiving wireless signals and/or other hardware such as a board for implementing a network communication function, in addition to the CPU, the memory, and the storage shown in fig. 7.
As shown in fig. 5, the present specification further provides a device 50 for recovering blockchain data, which is applied to a node device of a blockchain, where a system resource carried by the node device and a virtual resource published on the blockchain are value-anchored, and the device includes:
a receiving unit 502, configured to receive a data recovery transaction sent by a blockchain client, where the data recovery transaction includes identification information of target data to be recovered and an account identification of a user;
a calculating unit 504 that calculates a first amount of system resources of a node device consumed to process the data recovery transaction and determines a second amount of the virtual resources that are anchored to the first amount of system resource value;
a deduction unit 506, configured to deduct the second amount of virtual resources from the virtual resources held by the user account corresponding to the account identifier;
and the execution unit 508 is configured to execute the data recovery transaction after deduction, and recover the target data to the target intelligent contract account maintained by the user based on the identification information of the target data.
In yet another illustrated embodiment, the apparatus 50 further includes an allocating unit 510, configured to allocate the second amount of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier to the blockchain account corresponding to the node device of the blockchain for holding.
In yet another illustrated embodiment, the allocating unit 510 is further configured to:
the second amount of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier are averagely distributed to the blockchain accounts corresponding to the node devices of the blockchain to be held respectively;
or, based on the storage medium performance attribute of the account storage resource allocated to the intelligent contract by each node device of the blockchain, allocating the second number of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier to the blockchain accounts corresponding to each node device of the blockchain to hold the virtual resources respectively.
In yet another illustrated embodiment, the execution unit 508 is further configured to:
and restoring the target data from the backup database of the block chain to the target intelligent contract account maintained by the user.
In yet another illustrated embodiment, the execution unit 508 is further configured to:
re-executing the transaction associated with the target intelligent contract that is included in the blockchain until the target data determined based on the identification information of the target data is restored to the account storage space of the target intelligent contract.
In yet another illustrated embodiment, processing the data to recover system resources of the node device consumed by the transaction includes one or more of the following in combination:
processing computing resources of a node device consumed by the smart contract creation transaction;
processing network resources of the node device consumed by the smart contract creation transaction;
processing storage resources of the node device consumed by the smart contract creation transaction, the storage resources including storage resources of the node device occupied by the target data in the target smart contract account.
In yet another illustrated embodiment, the blockchain deploys a resource computation contract, and execution logic corresponding to contract code of the resource computation contract includes resource computation logic;
the calculating unit 504 is further configured to:
invoking the resource computation contract, executing the resource computation logic, computing a first amount of system resources of the node device consumed to process the data recovery transaction, and determining a second amount of the virtual resources anchored to the second amount of system resource values.
In a further illustrated embodiment, the blockchain maintains a remaining storage capacity of the account storage resources allocated by the node device for the target intelligent contract;
the apparatus 50 further comprises:
an updating unit 512, configured to update the remaining storage capacity of the account storage resource allocated to the target intelligent contract by the node device maintained by the block chain.
In another illustrated embodiment, the apparatus 50 further includes a returning unit 514, if the amount of the virtual resource held by the user account corresponding to the account identifier is smaller than the second amount, stopping executing the data recovery transaction, and returning a prompt indicating that the execution of the data recovery transaction fails to the blockchain client.
In yet another illustrated embodiment, the apparatus 50 further comprises a broadcasting unit 516 for broadcasting the data recovery transaction to a blockchain network for consensus verification of the data recovery transaction before the data recovery transaction is executed; wherein the consensus verification comprises: verifying whether the number of virtual resources held by the user account is not less than a preset threshold value;
if the consensus verification for the data recovery transaction passes, the execution unit 508 executes the data recovery transaction.
The implementation process of the function and the action of each unit in the apparatus 50 is specifically described in the implementation process of the corresponding step in the block chain data recovery method executed by the node device in the foregoing embodiment, and related points may be referred to the partial description of the method embodiment, and are not described herein again.
As shown in fig. 6, the present specification further provides a device 60 for recovering blockchain data, which is applied to a node device of a blockchain, where a system resource carried by the node device and a virtual resource published on the blockchain are value-anchored, and the device includes:
a receiving unit 602, configured to receive a data recovery transaction sent by a blockchain client, where the data recovery transaction includes identification information of target data to be recovered and an account identification of a user;
an executing unit 604, configured to execute the data recovery transaction, and recover the target data to a target intelligent contract account maintained by the user based on the identification information of the target data;
a calculating unit 606, after executing the data recovery transaction, calculating a first amount of system resources of the node device consumed for processing the data recovery transaction, and determining a second amount of the virtual resources anchored with the first amount of system resource value;
deduction unit 608, deduct the second amount of virtual resources from the virtual resources held by the user account corresponding to the account identifier.
In yet another illustrated embodiment, the apparatus 60 further comprises:
the allocating unit 610 allocates the second amount of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier to the blockchain account corresponding to the node device of the blockchain for holding.
In yet another illustrated embodiment, the allocation unit 610 is further configured to:
the second amount of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier are averagely distributed to the blockchain accounts corresponding to the node devices of the blockchain to be held respectively;
or, based on the storage medium performance attribute of the account storage resource allocated to the intelligent contract by each node device of the blockchain, allocating the second number of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier to the blockchain accounts corresponding to each node device of the blockchain to hold the virtual resources respectively.
In yet another illustrated embodiment, the executing unit 604 is further configured to:
and restoring the target data from the backup database of the blockchain to the account storage space of the target intelligent contract maintained by the user.
In yet another illustrated embodiment, the executing unit 604 is further configured to:
re-executing the transaction associated with the target intelligent contract that is included in the blockchain until the target data determined based on the identification information of the target data is restored to the account storage space of the target intelligent contract.
In yet another illustrated embodiment, processing the data to recover system resources of the node device consumed by the transaction includes one or more of the following in combination:
processing computing resources of a node device consumed by the smart contract creation transaction;
processing network resources of the node device consumed by the smart contract creation transaction;
processing storage resources of the node device consumed by the smart contract creation transaction, the storage resources including storage resources of the node device occupied by the target data in the target smart contract account.
In yet another illustrated embodiment, the blockchain deploys a resource computation contract, and execution logic corresponding to contract code of the resource computation contract includes resource computation logic;
the calculating unit 606 is further configured to:
invoking the resource computation contract, executing the resource computation logic, computing a first amount of system resources of the node device consumed to process the data recovery transaction, and determining a second amount of the virtual resources anchored to the second amount of system resource values.
In a further illustrated embodiment, the blockchain maintains a remaining storage capacity of the account storage resources allocated by the node device for the target intelligent contract;
the apparatus 60 further comprises:
an updating unit 612, after the data recovery transaction is executed, updates the remaining storage capacity of the account storage resource allocated by the node device maintained by the block chain for the target intelligent contract.
In yet another illustrated embodiment, the apparatus 60 further comprises:
a returning unit 614, configured to, if the second amount of virtual resources are successfully deducted from the virtual resources held by the user account corresponding to the account identifier, store the generated transaction receipt corresponding to the data recovery transaction in the blockchain, and return a prompt indicating that the data recovery transaction is completed to the blockchain client;
and if the quantity of the virtual resources held by the user account corresponding to the account identification is smaller than the second quantity, deleting the generated transaction receipt corresponding to the data recovery transaction, and returning a prompt of failure execution of the data recovery transaction to the blockchain client.
In yet another illustrated embodiment, the apparatus 60 further includes a broadcasting unit 616 that broadcasts the data recovery transaction to a blockchain network for consensus verification of the data recovery transaction before the data recovery transaction is performed; wherein the consensus verification comprises: verifying whether the number of virtual resources held by the user account is not less than a preset threshold value;
the execution unit executes the smart contract creation transaction if consensus verification of the data recovery transaction passes.
The implementation process of the function and the action of each unit in the apparatus 60 is specifically described in the implementation process of the corresponding step in the block chain data recovery method executed by the node device in the foregoing embodiment, and related points may be referred to part of the description of the method embodiment, and are not described herein again.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the units or modules can be selected according to actual needs to achieve the purpose of the solution in the specification. One of ordinary skill in the art can understand and implement it without inventive effort.
The apparatuses, units and modules described in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
Corresponding to the above method embodiment, the embodiment of the present specification further provides a computer device, as shown in fig. 7, including a memory and a processor. Wherein the memory has stored thereon a computer program executable by the processor; the processor, when running the stored computer program, performs the steps of the method for recovering blockchain data performed by the node device in which the apparatus shown in fig. 5 is located. For a detailed description of each step of the block chain data recovery method performed by the node device, please refer to the previous contents, which is not repeated.
Corresponding to the above method embodiment, the embodiment of the present specification further provides a computer device, as shown in fig. 7, including a memory and a processor. Wherein the memory has stored thereon a computer program executable by the processor; the processor, when running the stored computer program, performs the steps of the method for recovering blockchain data performed by the node device in which the apparatus shown in fig. 6 is located. For a detailed description of each step of the block chain data recovery method performed by the node device, please refer to the previous contents, which is not repeated.
The above description is only for the purpose of illustrating the preferred embodiments of the present disclosure and is not to be construed as limiting the present disclosure, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the present disclosure are intended to be included within the scope of the present disclosure.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The 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 Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.

Claims (15)

1. A block chain data recovery method is applied to node equipment of a block chain, and system resources carried on the node equipment and virtual resources issued on the block chain are subjected to value anchoring; the method comprises the following steps:
receiving a data recovery transaction which is sent by a blockchain client and corresponds to target data deleted from a target intelligent contract, wherein the data recovery transaction comprises an account identifier of a user;
calculating a first amount of the system resource consumed by processing the data recovery transaction and determining a second amount of the virtual resource anchored to the first amount of system resource value;
deducting the second amount of virtual resources from the virtual resources held by the user account corresponding to the account identifier;
after deducting the second amount of virtual resources from the virtual resources held by the user account, performing the data recovery transaction to recover the target data into the target intelligent contract.
2. The method of claim 1, further comprising:
and allocating the second amount of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier to the blockchain account corresponding to the node device of the blockchain for holding.
3. The method of claim 2, wherein allocating the second amount of virtual resources, deducted from the virtual resources held by the user account corresponding to the account identifier, to the blockchain account corresponding to the node device of the blockchain for holding comprises:
the second amount of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier are averagely distributed to the blockchain accounts corresponding to the node devices of the blockchain to be held respectively;
or, based on the storage medium performance attribute of the account storage resource allocated to the intelligent contract by each node device of the blockchain, allocating the second number of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier to the blockchain accounts corresponding to each node device of the blockchain to hold the virtual resources respectively.
4. The method of claim 1, processing the system resources consumed by the data recovery transaction, comprising a combination of one or more of:
processing the computing resources carried on the node equipment consumed by the intelligent contract creation transaction;
processing network resources piggybacked on the node device consumed by the smart contract creation transaction;
and processing the storage resources carried on the node equipment consumed by the intelligent contract creation transaction, wherein the storage resources comprise the storage resources carried on the node equipment occupied by the target data in the target intelligent contract account.
5. The method of claim 1, wherein the blockchain maintains a remaining storage capacity of account storage resources allocated by node devices for the target intelligent contract;
after the executing the data recovery transaction, further comprising:
and updating the residual storage capacity of the account storage resources allocated to the target intelligent contract by the node equipment maintained by the block chain.
6. The method of claim 1, prior to performing the data recovery transaction, the method further comprising:
broadcasting the data recovery transaction to a blockchain network for consensus verification of the data recovery transaction; wherein the consensus verification comprises: verifying whether the number of virtual resources held by the user account is not less than a preset threshold value;
and executing the data recovery transaction if the consensus verification on the data recovery transaction passes.
7. A block chain data recovery method is applied to node equipment of a block chain, and system resources carried on the node equipment and virtual resources issued on the block chain are subjected to value anchoring; the method comprises the following steps:
receiving a data recovery transaction which is sent by a blockchain client and corresponds to target data deleted from a target intelligent contract, wherein the data recovery transaction comprises an account identifier of a user;
executing the data recovery transaction to recover the target data into the target intelligent contract;
after restoring the target data into the target intelligent contract, calculating a first quantity of the system resources consumed for processing the data restoration transaction, determining a second quantity of the virtual resources anchored with the first quantity of system resource values, and deducting the second quantity of the virtual resources from the virtual resources held by the user account corresponding to the account identification.
8. The method of claim 7, further comprising:
and allocating the second amount of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier to the blockchain account corresponding to the node device of the blockchain for holding.
9. The method of claim 8, allocating the second amount of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier to the blockchain account corresponding to the node device of the blockchain for holding, comprising:
the second amount of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier are averagely distributed to the blockchain accounts corresponding to the node devices of the blockchain to be held respectively;
or, based on the storage medium performance attribute of the account storage resource allocated to the intelligent contract by each node device of the blockchain, allocating the second number of virtual resources deducted from the virtual resources held by the user account corresponding to the account identifier to the blockchain accounts corresponding to each node device of the blockchain to hold the virtual resources respectively.
10. The method of claim 7, processing the system resources consumed by the data recovery transaction, comprising a combination of one or more of:
processing the computing resources carried on the node equipment consumed by the intelligent contract creation transaction;
processing network resources piggybacked on the node device consumed by the smart contract creation transaction;
and processing the storage resources carried on the node equipment consumed by the intelligent contract creation transaction, wherein the storage resources comprise the storage resources carried on the node equipment occupied by the target data in the target intelligent contract account.
11. The method of claim 7, wherein the blockchain maintains a remaining storage capacity of account storage resources allocated by the node device for the target intelligent contract;
after the executing the data recovery transaction, further comprising:
and updating the residual storage capacity of the account storage resources allocated to the target intelligent contract by the node equipment maintained by the block chain.
12. The method of claim 7, prior to performing the data recovery transaction, the method further comprising:
broadcasting the data recovery transaction to a blockchain network for consensus verification of the data recovery transaction; wherein the consensus verification comprises: verifying whether the number of virtual resources held by the user account is not less than a preset threshold value;
and executing the intelligent contract creation transaction if the consensus verification of the data recovery transaction passes.
13. A block chain data recovery device is applied to node equipment of a block chain, and system resources carried on the node equipment and virtual resources released on the block chain are subjected to value anchoring; the device comprises:
the receiving unit is used for receiving a data recovery transaction which is sent by the block chain client and corresponds to target data deleted from the target intelligent contract, and the data recovery transaction comprises an account identifier of a user;
a computing unit to compute a first amount of the system resource consumed to process the data recovery transaction and to determine a second amount of the virtual resource anchored to the first amount of system resource value;
the deduction unit is used for deducting the virtual resources of the second quantity from the virtual resources held by the user account corresponding to the account identification;
and the execution unit is used for executing the data recovery transaction after deducting the second amount of virtual resources from the virtual resources held by the user account, and recovering the target data into the target intelligent contract maintained by the user.
14. A block chain data recovery device is applied to node equipment of a block chain, and system resources carried on the node equipment and virtual resources released on the block chain are subjected to value anchoring; the device comprises:
the receiving unit is used for receiving a data recovery transaction which is sent by the block chain client and corresponds to target data deleted from the target intelligent contract, and the data recovery transaction comprises an account identifier of a user;
the execution unit executes the data recovery transaction and recovers the target data into a target intelligent contract maintained by the user;
a computing unit to compute a first amount of the system resource consumed to process the data recovery transaction after recovering the target data into the target smart contract account, determine a second amount of the virtual resource anchored to the first amount of system resource value;
and the deduction unit is used for deducting the virtual resources of the second quantity from the virtual resources held by the user account corresponding to the account identification.
15. A computer device, comprising: a memory and a processor; the memory having stored thereon a computer program executable by the processor; the processor, when executing the computer program, performs the method of any of claims 1 to 6 or 7 to 12.
CN202110825650.XA 2020-10-20 2020-10-20 Block chain data recovery method and device Pending CN113886135A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110825650.XA CN113886135A (en) 2020-10-20 2020-10-20 Block chain data recovery method and device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110825650.XA CN113886135A (en) 2020-10-20 2020-10-20 Block chain data recovery method and device
CN202011128565.XA CN112015596B (en) 2020-10-20 2020-10-20 Block chain data recovery method and device

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202011128565.XA Division CN112015596B (en) 2020-10-20 2020-10-20 Block chain data recovery method and device

Publications (1)

Publication Number Publication Date
CN113886135A true CN113886135A (en) 2022-01-04

Family

ID=73527382

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202110825650.XA Pending CN113886135A (en) 2020-10-20 2020-10-20 Block chain data recovery method and device
CN202011128565.XA Active CN112015596B (en) 2020-10-20 2020-10-20 Block chain data recovery method and device

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN202011128565.XA Active CN112015596B (en) 2020-10-20 2020-10-20 Block chain data recovery method and device

Country Status (1)

Country Link
CN (2) CN113886135A (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112887432B (en) * 2021-03-31 2023-07-18 中国工商银行股份有限公司 Distributed system reconstruction operation and maintenance method, operation and maintenance node and system
CN113094755A (en) * 2021-05-10 2021-07-09 光载无限(北京)科技有限公司 Processing method and processing device for account information in block chain
KR20230046061A (en) * 2021-09-29 2023-04-05 삼성전자주식회사 Electronic device recovering block data and method in blockchain network

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180240112A1 (en) * 2014-06-16 2018-08-23 Bank Of America Corporation Block chain encryption tags
CN110392052A (en) * 2019-07-22 2019-10-29 中国工商银行股份有限公司 A kind of block chain intelligence contract processing system and method
CN110458702A (en) * 2019-07-15 2019-11-15 阿里巴巴集团控股有限公司 Based on the virtual resource allocation method and device of block chain, electronic equipment
CN110471795A (en) * 2019-07-31 2019-11-19 阿里巴巴集团控股有限公司 Block chain state data reconstruction method and device, electronic equipment
CN110597916A (en) * 2019-09-21 2019-12-20 腾讯科技(深圳)有限公司 Data processing method and device based on block chain, storage medium and terminal
US20200177519A1 (en) * 2019-07-15 2020-06-04 Alibaba Group Holding Limited Allocating virtual resource based on block chain
US20200201684A1 (en) * 2019-04-22 2020-06-25 Alibaba Group Holding Limited Blockchain-based virtual resource allocation
CN111414426A (en) * 2020-03-26 2020-07-14 北京云图科瑞科技有限公司 Data processing method and system based on block chain
US20200235947A1 (en) * 2017-02-17 2020-07-23 Nokia Technologies Oy Changing smart contracts recorded in block chains
CN111737765A (en) * 2020-07-31 2020-10-02 支付宝(杭州)信息技术有限公司 Method and device for managing block chain resources

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106547648A (en) * 2016-10-21 2017-03-29 杭州嘉楠耘智信息科技有限公司 Backup data processing method and device
CN108509536A (en) * 2018-03-07 2018-09-07 路亚鹏 A method of promote big data to collect and use with block chain technology
US11068316B2 (en) * 2018-12-24 2021-07-20 LiquidApps Ltd Systems and method for managing memory resources used by smart contracts of a blockchain
CN109615352B (en) * 2019-01-21 2024-04-05 深圳市祥云万维科技有限公司 Resource convergence network and method
CN111506925A (en) * 2020-03-25 2020-08-07 农业农村部农药检定所(国际食品法典农药残留委员会秘书处) Data processing system based on block chain
CN111383019A (en) * 2020-05-28 2020-07-07 支付宝(杭州)信息技术有限公司 Transaction execution method and system based on alliance link network

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20180240112A1 (en) * 2014-06-16 2018-08-23 Bank Of America Corporation Block chain encryption tags
US20200235947A1 (en) * 2017-02-17 2020-07-23 Nokia Technologies Oy Changing smart contracts recorded in block chains
US20200201684A1 (en) * 2019-04-22 2020-06-25 Alibaba Group Holding Limited Blockchain-based virtual resource allocation
CN110458702A (en) * 2019-07-15 2019-11-15 阿里巴巴集团控股有限公司 Based on the virtual resource allocation method and device of block chain, electronic equipment
US20200177519A1 (en) * 2019-07-15 2020-06-04 Alibaba Group Holding Limited Allocating virtual resource based on block chain
CN110392052A (en) * 2019-07-22 2019-10-29 中国工商银行股份有限公司 A kind of block chain intelligence contract processing system and method
CN110471795A (en) * 2019-07-31 2019-11-19 阿里巴巴集团控股有限公司 Block chain state data reconstruction method and device, electronic equipment
CN110597916A (en) * 2019-09-21 2019-12-20 腾讯科技(深圳)有限公司 Data processing method and device based on block chain, storage medium and terminal
CN111414426A (en) * 2020-03-26 2020-07-14 北京云图科瑞科技有限公司 Data processing method and system based on block chain
CN111737765A (en) * 2020-07-31 2020-10-02 支付宝(杭州)信息技术有限公司 Method and device for managing block chain resources

Also Published As

Publication number Publication date
CN112015596A (en) 2020-12-01
CN112015596B (en) 2021-05-28

Similar Documents

Publication Publication Date Title
WO2021008122A1 (en) Virtual resource allocation method and device employing blockchain, and electronic apparatus
US10986177B2 (en) Systems and methods of self-forking blockchain protocol
CN112015823B (en) Block chain data deleting method and device
CN112015596B (en) Block chain data recovery method and device
US11032215B2 (en) Allocating virtual resource based on block chain
WO2021017438A1 (en) Blockchain-based electronic bill cancellation method and apparatus, and electronic device
CN111966538B (en) Block chain data recovery method and device
CN111966757B (en) Method and device for managing storage space of intelligent contract account
CN112015822B (en) Block chain data deleting method and device
US20230283473A1 (en) Computer-implemented systems and methods relating to a binary blockchain comprising a pair of coupled blockchains
CN111967995A (en) Intelligent contract creating method and device
CN110599323B (en) Resource processing method and processing equipment
CN112015576A (en) Calling method and device of intelligent contract
CN111966503B (en) Method and device for managing storage space of intelligent contract account
CN110473030B (en) Block chain-based electronic bill number claiming method and device and electronic equipment
CN113037817B (en) Method and device for starting intelligent contract, electronic equipment and storage medium
CN112200571A (en) Resource distribution method and device based on block chain and electronic equipment
CN112200567A (en) Resource management method and device based on block chain and electronic equipment
CN110443612B (en) Block chain-based reimbursement expense segmentation method and device and electronic equipment
CN109886676A (en) Method of payment, calculating equipment, storage medium for block chain network
CN111967994B (en) Intelligent contract creating method and device
CN112015577B (en) Intelligent contract calling method and device

Legal Events

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