CN111339089A - Data storage and acquisition method and device applied to block chain - Google Patents

Data storage and acquisition method and device applied to block chain Download PDF

Info

Publication number
CN111339089A
CN111339089A CN202010107583.3A CN202010107583A CN111339089A CN 111339089 A CN111339089 A CN 111339089A CN 202010107583 A CN202010107583 A CN 202010107583A CN 111339089 A CN111339089 A CN 111339089A
Authority
CN
China
Prior art keywords
block
data
node
nodes
storing
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.)
Granted
Application number
CN202010107583.3A
Other languages
Chinese (zh)
Other versions
CN111339089B (en
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.)
Union Mobile Pay Co Ltd
Original Assignee
Linkage Advantage Beijing Digital 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 Linkage Advantage Beijing Digital Technology Co ltd filed Critical Linkage Advantage Beijing Digital Technology Co ltd
Priority to CN202010107583.3A priority Critical patent/CN111339089B/en
Publication of CN111339089A publication Critical patent/CN111339089A/en
Application granted granted Critical
Publication of CN111339089B publication Critical patent/CN111339089B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • 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/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Abstract

The invention discloses a data storage and acquisition method and a device applied to a block chain, wherein the method comprises the following steps: after the block data consensus succeeds, if the target node is determined not to be a node for storing the block data in the block data, storing block head data in the block data but not storing the block data in the block data; the target node is any node in the block chain network; the block data comprises the block volume data and the block header data; and the nodes for storing the block data in the block chain network are partial nodes in the block chain network.

Description

Data storage and acquisition method and device applied to block chain
Technical Field
The present invention relates to the field of blockchains, and in particular, to a data storage method and apparatus for a blockchain.
Background
Due to the characteristics of the blockchain, such as non-tamper-ability and consistency, the blockchain technology is increasingly applied to various fields. Therefore, memory read and write performance of the blockchain is critical to blockchain application quality of service.
In a conventional blockchain network, for a node, a newly generated block is stored in the node every time, and once the blockchain network runs for a long time, the amount of data of the block stored in the node is too large, so that the storage read-write performance of the whole blockchain network is poor, and the blockchain network becomes a bottleneck of the running performance of the whole blockchain network. Obviously, the storage read-write performance of the whole block chain network is poor due to the fact that the block chain network runs for too long, and the problem to be solved urgently is solved.
Disclosure of Invention
The application provides a data storage method and device applied to a block chain, and solves the problem that in the prior art, the storage read-write performance of the whole block chain network is poor due to the fact that the block chain network runs for a long time.
In a first aspect, the present application provides a data storage method applied to a block chain, including: after the block data consensus succeeds, if the target node is determined not to be a node for storing the block data in the block data, storing block head data in the block data but not storing the block data in the block data; the target node is any node in the block chain network; the block data comprises the block volume data and the block header data; and the nodes for storing the block data in the block chain network are partial nodes in the block chain network.
In the method, after the block data is successfully identified, the target node does not directly store the block data and the block header data in the target node, but determines whether the target node is the block data in the block data, and only stores the block header data in the block data if the target node is not the node for storing the block data, so that all data of the block data is not required to be stored.
In an alternative embodiment, the determining that the target node is not storing block data in the block data includes: the target node takes the data identification of the block data as the input of the node selection strategy, and determines a node set storing the block data in a block chain network according to the node selection strategy; and if the target node determines that the target node is not in the node set, determining that the target node is not the region block data in the storage of the region block data.
In the method, the target node uses the data identifier as an input of the node selection policy, determines a node set according to the node selection policy, and further determines that the target node is not a node for storing block data in the block data when the target node is determined not to be in the node set, so that a method for determining the node for storing the block data in the block chain network is provided without data interaction with the outside.
In an alternative embodiment, the node selection policy includes a number of nodes in the blockchain network that store the blocky data; the number range of the nodes is determined by a consensus algorithm of the block chain network; if the consensus algorithm is a practical Byzantine Fault tolerant PBFT consensus algorithm, then the number range is
Figure BDA0002388889040000021
Wherein M is the blockchain networkThe total number of the middle nodes is,
Figure BDA0002388889040000022
represents a lower rounding operation; or, if the consensus algorithm is the working evidence POW consensus algorithm, the number range is
Figure BDA0002388889040000023
In the method, under different consensus algorithms, the block volume data is stored by nodes with a certain number of nodes in the block chain network, so that the block volume data stored by at least one node in the node set of the target node is valid data,
Figure BDA0002388889040000031
the above are that
Figure BDA0002388889040000032
The nodes in the range store the block data, the block data stored in at least one node is guaranteed to be valid data, under the POW consensus algorithm,
Figure BDA0002388889040000033
the above are that
Figure BDA0002388889040000034
Figure BDA0002388889040000035
The nodes in the range store the block volume data, and the block volume data stored in at least one node is guaranteed to be valid data, so that under different consensus algorithms, the block volume data is stored in the nodes in the range, the correctness of data storage can be guaranteed, and the storage space of the data can be saved.
In an optional embodiment, if the consensus algorithm is a PBFT consensus algorithm, the number of nodes is
Figure BDA0002388889040000036
Or, if the consensus algorithm is a POW consensus algorithm, the number of the nodes is
Figure BDA0002388889040000037
In the mode, the storage space of the data is saved to the greatest extent on the basis of ensuring the correctness of the data storage under different consensus algorithms.
In an alternative embodiment, the node selection policy is a consistent node selection algorithm based on the number of nodes; the target node takes the data identifier of the block data as the input of the node selection policy, and determines the node set storing the block data in the block chain network according to the node selection policy, including: the target node takes the data identification as the input of the consistency node selection algorithm, and takes the nodes with the number of the nodes selected in the block chain network according to the consistency node selection algorithm as the node set of the target node; the consistent node selection algorithm is executed at each node in the blockchain network, so that node sets determined by each node in the blockchain network according to the node selection strategy are consistent.
In the above manner, the node selection policy is a consistent node selection algorithm based on the number of nodes; the consistency node selection algorithm is executed at each node in the block chain network, so that node sets determined by each node in the block chain network according to the node selection strategy are consistent, and therefore, the storage information of block storage data in each node in the block chain network can be guaranteed to be uniform.
In a second aspect, the present application provides a data acquisition method applied to a blockchain, including: a target node acquires a query request; the query request is used for acquiring a block to be queried; the block data to be inquired comprises block body data and block head data; if the target node determines that the block data is not stored in the target node, determining a node storing the block data in the block chain network; wherein, the nodes for storing the block data in the block chain network are partial nodes in the block chain network; the target node is any node in the block chain network; and the target node sends an acquisition request to a node storing the block volume data in the block chain network, so as to acquire the block volume data returned from the node.
In the method, after the target node acquires the query request, if it is determined that the block data is not stored in the target node, the node storing the block data in the block chain network is determined, and the acquisition request is sent, so that the block data returned from the node is acquired.
In an optional implementation manner, after the target node sends an acquisition request to a node in the blockchain network that stores the blockchain data, the method further includes: the target node acquires the data of the undetermined block volume returned by the node; the target node determines a hash value of head data of the undetermined block according to the undetermined block data; and if the target node determines that the hash value of the undetermined block head is consistent with the hash value of the block head data, determining that the undetermined block data acquired and returned from the node is the block data, and acquiring the returned block data from the node.
In a third aspect, the present application provides a data storage device applied to a blockchain, including: the determining module is used for determining whether the target node is a node for storing the block data in the block data after the block data is successfully identified; a storage module, configured to store block header data in the block data but not store block body data in the block data if the determination module determines that the target node is not a node for storing block body data in the block data; the target node is any node in the block chain network; the block data comprises the block volume data and the block header data; and the nodes for storing the block data in the block chain network are partial nodes in the block chain network.
In an optional implementation manner, the determining module is specifically configured to: taking the data identification of the block data as the input of the node selection strategy, and determining a node set storing the block data in a block chain network according to the node selection strategy; and if the target node is determined not to be in the node set, determining that the target node is not a node for storing block data in the block data.
In an alternative embodiment, the node selection policy includes a number of nodes in the blockchain network that store the blocky data; the number range of the nodes is determined by a consensus algorithm of the block chain network; if the consensus algorithm is a practical Byzantine Fault tolerant PBFT consensus algorithm, then the number range is
Figure BDA0002388889040000051
Wherein M is the total number of nodes in the blockchain network,
Figure BDA0002388889040000052
represents a lower rounding operation; or, if the consensus algorithm is the working evidence POW consensus algorithm, the number range is
Figure BDA0002388889040000053
In an optional embodiment, if the consensus algorithm is a PBFT consensus algorithm, the number of nodes is
Figure BDA0002388889040000054
Or, if the consensus algorithm is a POW consensus algorithm, the number of the nodes is
Figure BDA0002388889040000055
In an alternative embodiment, the node selection policy is a consistent node selection algorithm based on the number of nodes; the determining module is specifically configured to: the target node takes the data identification as the input of the consistency node selection algorithm, and takes the nodes with the number of the nodes selected in the block chain network according to the consistency node selection algorithm as the node set of the target node; the consistent node selection algorithm is executed at each node in the blockchain network, so that node sets determined by each node in the blockchain network according to the node selection strategy are consistent.
For the advantages of the third aspect and the embodiments of the third aspect, reference may be made to the advantages of the first aspect and the embodiments of the first aspect, which are not described herein again.
In a fourth aspect, the present application provides a data storage device applied to a block chain, including: the acquisition module is used for acquiring the query request; the query request is used for acquiring a block to be queried; the block data to be inquired comprises block body data and block head data; the processing module is used for determining a node storing the block volume data in the block chain network if it is determined that the block volume data is not stored in the target node; wherein, the nodes for storing the block data in the block chain network are partial nodes in the block chain network; the target node is any node in the block chain network; and sending an acquisition request to a node storing the block volume data in the block chain network, so that the acquisition module acquires the block volume data returned from the node.
In an optional implementation, the obtaining module is further configured to: acquiring data of the undetermined block volume returned by the node; the processing module is further configured to: determining a hash value of head data of the undetermined block according to the undetermined block volume data; and if the Hash value of the undetermined block head is consistent with the Hash value of the block head data, determining that the undetermined block data acquired and returned from the node is the block data, and acquiring the returned block data from the node.
The advantageous effects of the embodiments of the fourth aspect and the fourth aspect may refer to the advantageous effects of the embodiments of the second aspect and the second aspect, and are not described herein again.
In a fifth aspect, the present application provides a computer device comprising a program or instructions for performing the method of the first or second aspect and embodiments described above when the program or instructions are executed.
In a sixth aspect, the present application provides a storage medium comprising a program or instructions which, when executed, is adapted to perform the method of the embodiments of the first or second aspect.
Drawings
FIG. 1 is a schematic diagram of a blockchain;
fig. 2 is a schematic flowchart illustrating steps of a data storage method applied to a block chain according to an embodiment of the present application;
fig. 3 is a schematic diagram illustrating an architecture applicable to a data storage method applied to a block chain according to an embodiment of the present application;
fig. 4 is a schematic diagram illustrating specific steps of a data storage method applied to a block chain according to an embodiment of the present application;
fig. 5 is a schematic view of an application scenario of a data storage method applied to a block chain according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a data storage device applied to a block chain according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a data acquisition apparatus applied to a block chain according to an embodiment of the present disclosure.
Detailed Description
In order to better understand the technical solutions, the technical solutions will be described in detail below with reference to the drawings and the specific embodiments of the specification, and it should be understood that the specific features in the embodiments and examples of the present application are detailed descriptions of the technical solutions of the present application, but not limitations of the technical solutions of the present application, and the technical features in the embodiments and examples of the present application may be combined with each other without conflict.
The terms appearing in the embodiments of the present application are explained first below.
Block chains: as shown in fig. 1, a block chain is a chain consisting of a series of blocks, and each block records a Hash value of the block in addition to the data of the block, so that a chain is formed. The block chain has two core ideas, one is a cryptography technology, the other is a decentralization idea, and based on the two ideas, historical information on the block chain cannot be tampered.
And (3) node: each participant in the network is a node that participates in network set-up and data exchange. In a blockchain network, a node refers to a participant with a unique identity, and the node has a complete copy of the ledger and has the capability of participating in the consensus and ledger maintenance of the blockchain network.
Intelligent contract: an intelligent contract is a computer protocol intended to propagate, validate or execute contracts in an informational manner. Smart contracts allow trusted transactions to be conducted without third parties, which transactions are traceable and irreversible. The specific form of the intelligent contract is a code which is deployed on a block chain and completes a specific function. For example, identity is a mainstream intelligent contract programming language, and an intelligent contract written in the identity language is called an identity contract. When an intelligent contract is deployed on a blockchain, a contract address is generated, and a user can call the intelligent contract through the contract address. The function defined in the intelligent contract is called a contract interface, and the calling of the intelligent contract is to call a certain contract interface in the contract through a contract address.
Trading: a transaction is a user request for an operation of an intelligent contract interface deployed on a blockchain. The transaction is initiated by the user, sent from the client of the user to the block chain node, and after receiving the transaction, the block chain node calls the corresponding intelligent contract according to the contract address and the interface specified by the transaction. In blockchains, any operation (deploying a contract, invoking a contract interface, etc.) is done by sending a transaction. The transaction is initiated by the user and sent to the blockchain node through the client. After receiving the transaction, the blockchain node packs the transaction into blocks and executes the blocks.
Each transaction in the block is executed to generate a corresponding transaction receipt. The transaction receipt stores the execution result of the transaction, and typically contains important information such as a transaction hash, a status bit identifying whether the transaction was executed successfully, and a log generated during the execution.
As shown in fig. 2, a data storage method applied to a block chain is provided for the embodiment of the present application.
Step 201: and after the block data consensus is successful, the target node determines whether the target node is a node for storing the block data in the block data.
Step 202: and if the target node is determined not to be the node for storing the block data in the block data, storing the block head data in the block data but not storing the block data in the block data.
In step 201 to step 202, the target node is any node in the blockchain network; the block data comprises the block volume data and the block header data; and the nodes for storing the block data in the block chain network are partial nodes in the block chain network. Thus, the storage of the target node may be: a block head and a block body of the first block; a block head of the second block; a block head of block three; block head and block body of block four.
In an optional implementation manner of step 201, determining that the target node is not storing chunk data in the chunk data may be as follows:
the target node takes the data identification of the block data as the input of the node selection strategy, and determines a node set storing the block data in a block chain network according to the node selection strategy; and if the target node determines that the target node is not in the node set, determining that the target node is not the region block data in the storage of the region block data.
It should be noted that the data identifier of the block data may be various, as long as the block data can be uniquely identified. For example, the data identification of the chunk data is a transaction hash of the first transaction in the chunk data. The node selection policy is not limited, and any node that is finally selected can be obtained according to the node selection policy as long as the node is part of nodes in the blockchain network.
The above process includes, for example, node one, node two, node three, and node four in the blockchain network. And when the first node is not in the node set, determining that the first node is not the block data in the block data.
In an alternative embodiment, the node selection policy is a consistent node selection algorithm based on the number of nodes; the target node uses the data identifier of the block data as an input of the node selection policy, and a specific process of determining a node set storing the block data in the block chain network according to the node selection policy may be:
the target node takes the data identification as the input of the consistency node selection algorithm, and takes the nodes with the number of the nodes selected in the block chain network according to the consistency node selection algorithm as the node set of the target node; the consistent node selection algorithm is executed at each node in the blockchain network, so that node sets determined by each node in the blockchain network according to the node selection strategy are consistent.
The above process includes, for example, node one, node two, node three, and node four in the blockchain network. After the first node, the second node, the third node and the fourth node know the block data successfully, the transaction hash of the first transaction of the block data is used as the input of a node selection strategy, and the node sets obtained by the first node, the second node, the third node and the fourth node are the second node and the third node.
The consistency node selection algorithm may be any one of the following algorithms: a node polling algorithm; a node weight polling algorithm; a node identifier sorting algorithm; the random function VRF algorithm may be verified.
It should be noted that the node selection policy may include the number of nodes storing the block data in the block chain network; the number range of the nodes is determined by a consensus algorithm of the blockchain network, in particular:
if the consensus algorithm is a practical Byzantine Fault tolerant PBFT consensus algorithm, then the number range is
Figure BDA0002388889040000101
Wherein M is the total number of nodes in the blockchain network,
Figure BDA0002388889040000102
represents a lower rounding operation; or, if the consensus algorithm is the working evidence POW consensus algorithm, the number range is
Figure BDA0002388889040000103
Figure BDA0002388889040000104
For example, when M is 10, then for the PBFT consensus algorithm, the number range is [4, 10); for the POW consensus algorithm, the number range is [6,10 ].
Under different consensus algorithms, the block volume data is stored by nodes with more than a certain number of nodes in the block chain network, so that the block volume data stored by at least one node in the node set of the target node is valid data. That is, the number range may be determined according to the consensus algorithm; any number in the range of numbers is such that at least one node in the blockchain network stores a value that the blockvolume data is real data. Under the PBFT consensus algorithm,
Figure BDA0002388889040000105
the above are that
Figure BDA0002388889040000106
Figure BDA0002388889040000107
The nodes in the range store the block data, the block data stored in at least one node is guaranteed to be valid data, under the POW consensus algorithm,
Figure BDA0002388889040000108
the above are that
Figure BDA0002388889040000109
The nodes in the range store the block volume data, and the block volume data stored in at least one node is guaranteed to be valid data, so that under different consensus algorithms, the block volume data is stored in the nodes in the range, the correctness of data storage can be guaranteed, and the storage space of the data can be saved.
In a more specific optional implementation manner, if the consensus algorithm is a PBFT consensus algorithm, the number of nodes is
Figure BDA00023888890400001010
Or, if the consensus algorithm is a POW consensus algorithm, the number of the nodes is
Figure BDA00023888890400001011
For example, when M is 20, for the PBFT consensus algorithm, the number of nodes is 7; for the POW consensus algorithm, the number of nodes is 11.
In the mode, the storage space of the data is saved to the greatest extent on the basis of ensuring the correctness of the data storage under different consensus algorithms.
In the method of step 201 to step 202, after the block data is successfully identified, the target node does not directly store the block data and the block header data in the target node, but first determines whether the target node is a node for storing the block data in the block data, and if not, only stores the block header data in the block data, so that all data of the block data is not needed to be stored.
After the data storage method of steps 201 to 202 is performed, since each block data is only stored in a part of nodes in the blockchain network, when a node is requested for a block data, the node may not have all block data, but only block volume data.
Therefore, the application provides a data acquisition method applied to a block chain, and specifically comprises the following steps:
the target node obtains the query request.
The query request is used for acquiring a block to be queried. The block data to be inquired comprises block volume data and block head data.
And if the target node determines that the block data is not stored in the target node, determining a node storing the block data in the block chain network. Wherein, the nodes for storing the block data in the block chain network are partial nodes in the block chain network; the target node is any node in the blockchain network.
And the target node sends an acquisition request to a node storing the block volume data in the block chain network, so as to acquire the block volume data returned from the node.
It should be noted that, when the target node selects the node of the storage block data by using a node selection policy during storage, and the node selection policy includes the number of nodes storing the block data in the block chain network, where the number range of the nodes is determined by a consensus algorithm of the block chain network. When the number of nodes of the block data in the storage area is more, the space for the nodes to communicate with each other is smaller, and when the number of the nodes is more than a certain storage threshold value, at least one node can be ensuredThe stored block volume data is available efficiently. The number range of the specific number of nodes can be determined according to the consensus algorithm of the blockchain network, so that the block volume data stored by at least one node is effectively available. If the consensus algorithm is a practical Byzantine Fault tolerant PBFT consensus algorithm, then the number range is
Figure BDA0002388889040000121
Wherein M is the total number of nodes in the blockchain network,
Figure BDA0002388889040000122
represents a lower rounding operation; or, if the consensus algorithm is the working evidence POW consensus algorithm, the number range is
Figure BDA0002388889040000123
When the target node queries the block data, the data of the pending block fed back by at least one node is available.
In the method, after the target node acquires the query request, if it is determined that the block data is not stored in the target node, the node storing the block data in the block chain network is determined, and the acquisition request is sent, so that the block data returned from the node is acquired.
In an optional implementation manner, after the target node sends an acquisition request to a node in the blockchain network that stores the blockchain data, the method further includes: the target node acquires the data of the undetermined block volume returned by the node; the target node determines a hash value of head data of the undetermined block according to the undetermined block data; and if the target node determines that the hash value of the undetermined block head is consistent with the hash value of the block head data, determining that the undetermined block data acquired and returned from the node is the block data, and acquiring the returned block data from the node.
When a target node selects a node storing block data by adopting a node selection strategy during storage, and the node selection strategy comprises the number of nodes storing the block data in the block chain network, as the undetermined block data returned by at least one node is correct and effective, under the method, the target node can obtain at least one undetermined block data, so that the hash value of the head of the undetermined block is consistent with the hash value of the head data of the block, and the returned block data is obtained from the node.
A data storage method applied to a blockchain according to the present application is described in detail below with reference to fig. 3 and 4. After the nodes receive the block data which are identified in common, the common identification is achieved through the interface module, the transaction management module, the execution of the intelligent contract and the multiple nodes, and the accounting book module stores the blocks of each node. The node executes the transaction in the block, completes the update of the state data, and the ledger module stores the state data. After the account book module receives the block, the block data is split into block body data and block head data, and the storage block head data is stored. And judging whether the current node stores the block data according to the node selection strategy by the account book module. If so, the block data is stored. Otherwise, the block data is not stored. After the query module receives the query request, the node where the block data is located is obtained through a consistent node selection algorithm according to the queried block number, and the node containing the block is queried.
Specifically, the node selection strategy comprises two steps: node number selection and specific node selection. Wherein the number of nodes is different according to different consensus algorithms. For the PBFT-like consensus algorithm, if the number of nodes is 3f +1 (f is a positive integer greater than or equal to 1), the key field of the block data, then at least f +1 nodes are required for storing the block data in each newly generated block. f represents the number of Byzantine nodes, and the POW type consensus algorithm is adopted, if the number of the nodes is 2f +1 (f is a positive integer greater than or equal to 1), at least f +1 nodes are required for storing block data in each newly generated block. Other consensus algorithms also require that the number of stored nodes is at least greater than the number of byzantine nodes.
As shown in fig. 4, the complete flow includes the following steps:
step 401: the target node shares the block data.
After the target node formula block data is successful, step 402 is performed.
Step 402: the target node stores state data in the chunk data.
Step 403: and splitting the block head data and the block body data in the block data by the target node, and storing the block head data.
Step 404: and the target node obtains a node set of the storage block according to a consistency algorithm.
Step 405: it is determined whether the target node is in the set of nodes.
If yes, go to step 406, otherwise go to step 407.
Step 406: block volume data in the block data is stored.
Step 407: and discarding the block data in the block data.
The following describes the data storage method shown in fig. 1 in detail with reference to the scenario shown in fig. 5, and a PBFT consensus algorithm is used through a block chain system, where the total number of nodes is 4, and the nodes are a, B, C, and D, respectively. Wherein the D node is a byzantine node.
The node B initiates a transaction to be completed.
For each of A, B, C and D nodes, performing the steps of:
the ledger module stores block header data and status data. The account book module determines and selects at least F +1 nodes according to a consensus algorithm to store data, wherein F is 1, namely two nodes store full data. And the account book module selects specific A nodes and C nodes to store block data through a VRF random selection algorithm according to the current block height and the HASH of the block head.
Entering the next round of consensus.
When a certain node needs to inquire data in a block body, the node where the block is located is preferentially determined through a VRF verifiable algorithm according to the block number, if the node is the current node, a local database is inquired, and if the node is not the current node, block data is requested from the corresponding node. And after the data is acquired, verifying the hash of the block and the hash of the head of the local block. If the data are consistent, the data are correct, otherwise, the data are wrong, and the next node is requested to acquire the data. And returning data errors if the data are inconsistent until the consistent data are acquired.
As shown in fig. 6, the present application provides a data storage device applied to a block chain, including: a determining module 601, configured to determine whether a target node is a node for storing chunk data in the chunk data after the chunk data consensus is successful; a storage module 602, configured to store block header data in the block data but not store block volume data in the block data if the determining module 601 determines that the target node is not a node for storing block volume data in the block data; the target node is any node in the block chain network; the block data comprises the block volume data and the block header data; and the nodes for storing the block data in the block chain network are partial nodes in the block chain network.
In an optional implementation manner, the determining module 601 is specifically configured to: taking the data identification of the block data as the input of the node selection strategy, and determining a node set storing the block data in a block chain network according to the node selection strategy; and if the target node is determined not to be in the node set, determining that the target node is not a node for storing block data in the block data.
In an alternative embodiment, the node selection policy includes a number of nodes in the blockchain network that store the blocky data; the number range of the nodes is determined by a consensus algorithm of the block chain network; if the consensus algorithm is a practical Byzantine Fault tolerant PBFT consensus algorithm, then the number range is
Figure BDA0002388889040000151
Wherein M is as defined aboveThe total number of nodes in the blockchain network,
Figure BDA0002388889040000152
represents a lower rounding operation; or, if the consensus algorithm is the working evidence POW consensus algorithm, the number range is
Figure BDA0002388889040000153
In an optional embodiment, if the consensus algorithm is a PBFT consensus algorithm, the number of nodes is
Figure BDA0002388889040000154
Or, if the consensus algorithm is a POW consensus algorithm, the number of the nodes is
Figure BDA0002388889040000155
In an alternative embodiment, the node selection policy is a consistent node selection algorithm based on the number of nodes; the determining module 601 is specifically configured to: the target node takes the data identification as the input of the consistency node selection algorithm, and takes the nodes with the number of the nodes selected in the block chain network according to the consistency node selection algorithm as the node set of the target node; the consistent node selection algorithm is executed at each node in the blockchain network, so that node sets determined by each node in the blockchain network according to the node selection strategy are consistent.
As shown in fig. 7, the present application provides a data storage device applied to a block chain, including: an obtaining module 701, configured to obtain a query request; the query request is used for acquiring a block to be queried; the block data to be inquired comprises block body data and block head data; a processing module 702, configured to determine a node in the blockchain network that stores the chunk data if it is determined that the chunk data is not stored in the target node; wherein, the nodes for storing the block data in the block chain network are partial nodes in the block chain network; the target node is any node in the block chain network; an acquisition request is sent to a node storing the block volume data in the blockchain network, so that the acquisition module 701 acquires the block volume data returned from the node.
In an optional implementation manner, the obtaining module 701 is further configured to: acquiring data of the undetermined block volume returned by the node; the processing module 702 is further configured to: determining a hash value of head data of the undetermined block according to the undetermined block volume data; and if the Hash value of the undetermined block head is consistent with the Hash value of the block head data, determining that the undetermined block data acquired and returned from the node is the block data, and acquiring the returned block data from the node.
The embodiment of the present application provides a computer device, which includes a program or an instruction, and when the program or the instruction is executed, the program or the instruction is used to execute a data storage method applied to a block chain and any optional method provided by the embodiment of the present application.
The embodiment of the present application provides a storage medium, which includes a program or an instruction, and when the program or the instruction is executed, the program or the instruction is used to execute a data storage method applied to a block chain and any optional method provided by the embodiment of the present application.
Finally, it should be noted that: as will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application 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, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.

Claims (10)

1. A data storage method applied to a block chain is characterized by comprising the following steps:
after the block data consensus succeeds, if the target node is determined not to be a node for storing the block data in the block data, storing block head data in the block data but not storing the block data in the block data; the target node is any node in the block chain network; the block data comprises the block volume data and the block header data; and the nodes for storing the block data in the block chain network are partial nodes in the block chain network.
2. The method of claim 1, wherein said determining that the target node is not storing partitioned block data in the block data comprises:
the target node takes the data identification of the block data as the input of the node selection strategy, and determines a node set storing the block data in a block chain network according to the node selection strategy;
and if the target node is determined not to be in the node set, determining that the target node is not a node for storing block data in the block data.
3. The method of claim 2, wherein the node selection policy comprises a number of nodes in the blockchain network that store the blockvolume data; the number range of the nodes is determined by a consensus algorithm of the block chain network;
if the consensus algorithm is a practical Byzantine Fault tolerant PBFT consensus algorithm, then the number range is
Figure FDA0002388889030000011
Wherein M is the total number of nodes in the blockchain network,
Figure FDA0002388889030000012
represents a lower rounding operation;
or, if the consensus algorithm is the working evidence POW consensus algorithm, the number range is
Figure FDA0002388889030000013
4. The method of claim 3, wherein if the consensus algorithm is a PBFT consensus algorithm, then the number of nodes is
Figure FDA0002388889030000014
Or, if the consensus algorithm is a POW consensus algorithm, the number of the nodes is
Figure FDA0002388889030000021
5. The method of claim 3 or 4, wherein the node selection policy is a consistent node selection algorithm based on the number of nodes; the target node takes the data identifier of the block data as the input of the node selection policy, and determines the node set storing the block data in the block chain network according to the node selection policy, including:
the target node takes the data identification as the input of the consistency node selection algorithm, and takes the nodes with the number of the nodes selected in the block chain network according to the consistency node selection algorithm as the node set of the target node; the consistent node selection algorithm is executed at each node in the blockchain network, so that node sets determined by each node in the blockchain network according to the node selection strategy are consistent.
6. A data acquisition method applied to a blockchain is characterized by comprising the following steps:
a target node acquires a query request; the query request is used for acquiring a block to be queried; the block data to be inquired comprises block body data and block head data;
if the target node determines that the block data is not stored in the target node, determining a node storing the block data in the block chain network; wherein, the nodes for storing the block data in the block chain network are partial nodes in the block chain network; the target node is any node in the block chain network;
and the target node sends an acquisition request to a node storing the block volume data in the block chain network, so as to acquire the block volume data returned from the node.
7. The method of claim 6, wherein after the target node sends an acquisition request to a node in the blockchain network that stores the blockvolume data, further comprising:
the target node acquires the data of the undetermined block volume returned by the node;
the target node determines a hash value of head data of the undetermined block according to the undetermined block data;
and if the target node determines that the hash value of the undetermined block head is consistent with the hash value of the block head data, determining that the undetermined block data acquired and returned from the node is the block data, and acquiring the returned block data from the node.
8. A data storage device for use with a blockchain, comprising:
the determining module is used for determining whether the target node is a node for storing the block data in the block data after the block data is successfully identified;
a storage module, configured to store block header data in the block data but not store block body data in the block data if the determination module determines that the target node is not a node for storing block body data in the block data; the target node is any node in the block chain network; the block data comprises the block volume data and the block header data; and the nodes for storing the block data in the block chain network are partial nodes in the block chain network.
9. A data acquisition device for use in a blockchain, comprising:
the acquisition module is used for acquiring the query request; the query request is used for acquiring a block to be queried; the block data to be inquired comprises block body data and block head data;
the processing module is used for determining a node storing the block volume data in the block chain network if it is determined that the block volume data is not stored in the target node; wherein, the nodes for storing the block data in the block chain network are partial nodes in the block chain network; the target node is any node in the block chain network; and sending an acquisition request to a node storing the block volume data in the block chain network, so that the acquisition module acquires the block volume data returned from the node.
10. A computer device comprising a program or instructions that, when executed, perform the method of any of claims 1 to 5 or 6 to 7.
CN202010107583.3A 2020-02-21 2020-02-21 Data storage and acquisition method and device applied to blockchain Active CN111339089B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010107583.3A CN111339089B (en) 2020-02-21 2020-02-21 Data storage and acquisition method and device applied to blockchain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010107583.3A CN111339089B (en) 2020-02-21 2020-02-21 Data storage and acquisition method and device applied to blockchain

Publications (2)

Publication Number Publication Date
CN111339089A true CN111339089A (en) 2020-06-26
CN111339089B CN111339089B (en) 2023-09-22

Family

ID=71184147

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010107583.3A Active CN111339089B (en) 2020-02-21 2020-02-21 Data storage and acquisition method and device applied to blockchain

Country Status (1)

Country Link
CN (1) CN111339089B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112988903A (en) * 2021-04-22 2021-06-18 腾讯科技(深圳)有限公司 Data processing method, device and equipment based on block chain network and storage medium

Citations (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018112805A1 (en) * 2016-12-21 2018-06-28 深圳前海达闼云端智能科技有限公司 Blockchain storage method and device, and node device
CN108537063A (en) * 2018-02-26 2018-09-14 阿里巴巴集团控股有限公司 A kind of method, apparatus and equipment of data storage
CN108769230A (en) * 2018-06-06 2018-11-06 腾讯科技(深圳)有限公司 Transaction data storage method, device, server and storage medium
CN109324757A (en) * 2018-08-22 2019-02-12 深圳前海微众银行股份有限公司 Block chain data capacity reduction method, device and storage medium
CN109508982A (en) * 2018-11-21 2019-03-22 北京蓝石环球区块链科技有限公司 REPB common recognition based on the more subchains of block chain main chain adduction row
CN109522362A (en) * 2018-10-17 2019-03-26 北京瑞卓喜投科技发展有限公司 Incomplete markets synchronous method, system and equipment based on block chain data
CN109636388A (en) * 2018-12-07 2019-04-16 深圳市智税链科技有限公司 Data processing method, device, medium and electronic equipment in block chain network
CN109842606A (en) * 2018-02-24 2019-06-04 中国科学院计算技术研究所 Block chain common recognition algorithm and system based on consistency hash algorithm
US20190188086A1 (en) * 2017-12-14 2019-06-20 International Business Machines Corporation Redundancy reduction in blockchains
WO2019179540A2 (en) * 2019-07-11 2019-09-26 Alibaba Group Holding Limited Shared blockchain data storage
CN110472116A (en) * 2018-04-28 2019-11-19 腾讯科技(深圳)有限公司 Alliance's block chain business network and its federation node, product data storage method
WO2019228550A2 (en) * 2019-08-20 2019-12-05 Alibaba Group Holding Limited Blockchain data storage based on shared nodes and error correction code
CN110602116A (en) * 2019-09-19 2019-12-20 腾讯科技(深圳)有限公司 Block chain based data verification method, device and computer readable storage medium
CN110633323A (en) * 2019-09-16 2019-12-31 腾讯科技(深圳)有限公司 Business data storage method, device, storage medium and computer equipment
CN110730225A (en) * 2019-09-30 2020-01-24 北京中电拓方科技股份有限公司 Data processing method of Internet of things based on block chain, Internet of things and storage medium
WO2020035088A2 (en) * 2019-11-06 2020-02-20 Alipay (Hangzhou) Information Technology Co., Ltd. Prioritizing shared blockchain data storage

Patent Citations (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018112805A1 (en) * 2016-12-21 2018-06-28 深圳前海达闼云端智能科技有限公司 Blockchain storage method and device, and node device
US20190188086A1 (en) * 2017-12-14 2019-06-20 International Business Machines Corporation Redundancy reduction in blockchains
CN109842606A (en) * 2018-02-24 2019-06-04 中国科学院计算技术研究所 Block chain common recognition algorithm and system based on consistency hash algorithm
CN108537063A (en) * 2018-02-26 2018-09-14 阿里巴巴集团控股有限公司 A kind of method, apparatus and equipment of data storage
CN110472116A (en) * 2018-04-28 2019-11-19 腾讯科技(深圳)有限公司 Alliance's block chain business network and its federation node, product data storage method
CN108769230A (en) * 2018-06-06 2018-11-06 腾讯科技(深圳)有限公司 Transaction data storage method, device, server and storage medium
CN109324757A (en) * 2018-08-22 2019-02-12 深圳前海微众银行股份有限公司 Block chain data capacity reduction method, device and storage medium
CN109522362A (en) * 2018-10-17 2019-03-26 北京瑞卓喜投科技发展有限公司 Incomplete markets synchronous method, system and equipment based on block chain data
CN109508982A (en) * 2018-11-21 2019-03-22 北京蓝石环球区块链科技有限公司 REPB common recognition based on the more subchains of block chain main chain adduction row
CN109636388A (en) * 2018-12-07 2019-04-16 深圳市智税链科技有限公司 Data processing method, device, medium and electronic equipment in block chain network
WO2019179540A2 (en) * 2019-07-11 2019-09-26 Alibaba Group Holding Limited Shared blockchain data storage
WO2019228550A2 (en) * 2019-08-20 2019-12-05 Alibaba Group Holding Limited Blockchain data storage based on shared nodes and error correction code
CN110633323A (en) * 2019-09-16 2019-12-31 腾讯科技(深圳)有限公司 Business data storage method, device, storage medium and computer equipment
CN110602116A (en) * 2019-09-19 2019-12-20 腾讯科技(深圳)有限公司 Block chain based data verification method, device and computer readable storage medium
CN110730225A (en) * 2019-09-30 2020-01-24 北京中电拓方科技股份有限公司 Data processing method of Internet of things based on block chain, Internet of things and storage medium
WO2020035088A2 (en) * 2019-11-06 2020-02-20 Alipay (Hangzhou) Information Technology Co., Ltd. Prioritizing shared blockchain data storage
CN111417930A (en) * 2019-11-06 2020-07-14 支付宝(杭州)信息技术有限公司 Prioritizing shared blockchain data storage

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘敬浩;平鉴川;付晓梅;: "一种基于区块链的分布式公钥管理方案研究", 信息网络安全, no. 08 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112988903A (en) * 2021-04-22 2021-06-18 腾讯科技(深圳)有限公司 Data processing method, device and equipment based on block chain network and storage medium

Also Published As

Publication number Publication date
CN111339089B (en) 2023-09-22

Similar Documents

Publication Publication Date Title
EP3678346B1 (en) Blockchain smart contract verification method and apparatus, and storage medium
CN109034809B (en) Block chain generation method and device, block chain node and storage medium
CN110597925B (en) Cross-chain data processing method and device based on block chain
CN106453415B (en) Block chain-based equipment authentication method, authentication server and user equipment
CN112153085B (en) Data processing method, node and block chain system
CN111144883B (en) Processing performance analysis method and device for blockchain network
US20180308091A1 (en) Fairness preserving byzantine agreements
CN110868440A (en) Block chain male chain
CN110032571A (en) Business flow processing method, apparatus, storage medium and calculating equipment
US20210049715A1 (en) Blockchain-based data procesing method, apparatus, and electronic device
CN109255056B (en) Data reference processing method, device, equipment and storage medium of block chain
CN111026767B (en) Block chain data storage method and device and hardware equipment
CN111899019A (en) Method and system for cross validation and sharing of blacklist and multiple parties
US20230275771A1 (en) Pre-execution of block chain transaction in parallel during block consensus
CN110599175A (en) Block processing method and related equipment
CN110597922A (en) Data processing method, device, terminal and storage medium
CN111339089A (en) Data storage and acquisition method and device applied to block chain
WO2021184873A1 (en) Method and apparatus for data synchronization in blockchain network, and computing device
CN113411373A (en) Transaction data storage method, tracking and tracing method and block chain network
CN109067849A (en) Method of data synchronization based on block
CN111737351A (en) Transaction management method and device for distributed management system
CN110879900A (en) Data processing method and device based on block chain system
CN115422184A (en) Data acquisition method, device, equipment and storage medium
CN113507528B (en) Data processing method and electronic equipment
CN109410049A (en) Block chain bookkeeping methods, device, computer equipment and storage medium

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
CB02 Change of applicant information

Address after: Room 501, 5 / F, block B, No. 28, Xinjiekou Wai Street, Xicheng District, Beijing 100032

Applicant after: Joint digital technology (Beijing) Co.,Ltd.

Address before: Room 501, 5 / F, block B, No. 28, Xinjiekou Wai Street, Xicheng District, Beijing 100032

Applicant before: Linkage advantage (Beijing) Digital Technology Co.,Ltd.

CB02 Change of applicant information
TA01 Transfer of patent application right

Effective date of registration: 20220119

Address after: 100082 7th floor, block a, Jingshi science and technology building, 12 Xueyuan South Road, Haidian District, Beijing

Applicant after: UNION MOBILE PAY Co.,Ltd.

Address before: Room 501, 5 / F, block B, No. 28, Xinjiekou Wai Street, Xicheng District, Beijing 100032

Applicant before: Joint digital technology (Beijing) Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant