CN112650734B - Block repairing method and related device - Google Patents

Block repairing method and related device Download PDF

Info

Publication number
CN112650734B
CN112650734B CN202011601364.7A CN202011601364A CN112650734B CN 112650734 B CN112650734 B CN 112650734B CN 202011601364 A CN202011601364 A CN 202011601364A CN 112650734 B CN112650734 B CN 112650734B
Authority
CN
China
Prior art keywords
block
target block
current target
repair
proposal
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.)
Active
Application number
CN202011601364.7A
Other languages
Chinese (zh)
Other versions
CN112650734A (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.)
Hangzhou Qulian Technology Co Ltd
Original Assignee
Hangzhou Qulian 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 Hangzhou Qulian Technology Co Ltd filed Critical Hangzhou Qulian Technology Co Ltd
Priority to CN202011601364.7A priority Critical patent/CN112650734B/en
Publication of CN112650734A publication Critical patent/CN112650734A/en
Application granted granted Critical
Publication of CN112650734B publication Critical patent/CN112650734B/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/21Design, administration or maintenance of databases
    • G06F16/217Database tuning
    • 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/2246Trees, e.g. B+trees
    • 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
    • G06F16/2379Updates performed during online database operations; commit processing
    • 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

Landscapes

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

Abstract

The application provides a block repairing method and a related device, which relate to the technical field of block chains, and the block repairing method comprises the following steps: receiving a block repairing instruction, positioning a block to be repaired (a block allowed to be repaired in a block chain is confirmed by voting) based on block height indication information in the block repairing instruction, replacing source block data in the block to be repaired with target block data, recalculating and updating the target block parameters of the block to be repaired and a block generated later, and achieving the effect of deleting and modifying part of the block data.

Description

Block repairing method and related device
Technical Field
The present disclosure relates to the field of block chaining technologies, and in particular, to a block repairing method and a related apparatus.
Background
The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like, all nodes in a network commonly own, manage and supervise data through a cryptography technology, and the block chain has the characteristics of decentralization, unforgeability, no falsification, traceability and the like.
Due to the characteristic that the block chain is not capable of being tampered, an insurmountable obstacle is easy to appear in some scenes, for example, a user maliciously publishes sensitive information such as violence, pornography and the like on the block chain and confirms the sensitive information on the block chain, and the sensitive information is permanently stored on the block chain, which brings great difficulty to supervision and examination.
In view of this situation, the conventional method generally performs hard forking, i.e. extending a new block branch from a previous block of the attacked block (i.e. generating the above-mentioned sensitive information), and discards the attacked fork. For example, as shown in fig. 1, blocks A1 to A6 represent blocks sequentially generated in a certain block chain, and in the prior art, when it is detected that block A4 is attacked, a hard bifurcation manner is adopted to extend a new block branch after block A3, i.e., a block is re-taken from after block A3 (e.g., in fig. 1, a new block A7 is generated after block A3, a new block A8 is generated after block A7, and so on).
As can be seen from fig. 1, the hard forking approach described above is more harmful to users of the blockchain, because the transactions (e.g., blocks A5 and A6) after the attacked block (e.g., block A4) are invalidated, which impairs the operation of the entire blockchain.
Disclosure of Invention
The application provides a block repairing method and a related device, which can reduce damage to operation of a block chain while realizing block repairing.
In order to achieve the above technical effect, a first aspect of the present application provides a block repairing method, including:
receiving a block repair command, wherein the block repair command comprises: the method comprises the steps of obtaining block height indication information of a block to be repaired, source block data and target block data, wherein the block to be repaired is a block which is allowed to be repaired in a block chain after voting confirmation;
positioning the block to be repaired based on the block height indication information;
taking the block to be repaired as a current target block, and replacing the source block data stored in the current target block with the target block data;
recalculating and updating target block parameters of the current target block, wherein the target block parameters are parameters related to block data stored in a related block in the block parameters;
and taking the next block of the current target block as the current target block, and returning to the step of recalculating and updating the target block parameters of the current target block until the target block parameters of the last block in the block chain are updated.
Based on the first aspect of the present application, in a first possible implementation manner, after the target block parameter of the last block is updated, the block repairing method further includes:
and recording the current block repairing event in the block chain.
Based on the first aspect of the present application or the first possible implementation manner of the first aspect of the present application, in a second possible implementation manner, the target block parameter includes: a transaction tree root value, a receipt tree root value, a status tree root value, a block signature, and a hash pointer to a parent block;
the recalculating and updating the target block parameters of the current target block comprises:
calculating and updating a transaction tree root value of the current target block based on the hash lists of all transactions in the current target block;
calculating and updating a receipt tree root value of the current target block based on the hash list of all transaction receipts in the current target block;
calculating and updating a state tree root value of the current target block based on the hash list of all account states in the current target block;
updating a hash pointer pointing to a parent block in a block head of the current target block;
a block signature is generated and updated based on the block header content of the current target block.
Based on the first aspect of the present application or the first possible implementation manner of the first aspect of the present application, in a third possible implementation manner, a committee exists in the block chain, and the committee has a voting function and a repair triggering function; the voting function comprises: when a proposal is received, triggering each block yield time of N blocks produced later by each member in the committee to vote on the proposal so as to support or object the repair of the related block of the proposal, wherein each proposal comprises: the method comprises the following steps of (1) indicating information of block height, source block data, target block data and repair reasons, wherein N is a preset value larger than 2;
the repair trigger function includes: counting all votes of each member in the committee for the proposal after the last vote for the proposal is finished; when the accumulated number of supported tickets aiming at the proposal is more than the accumulated number of anti-tickets, outputting a corresponding block repair instruction based on the proposal;
the received block repair command includes: a block repair instruction is received from the committee.
A second aspect of the present application provides a block repair apparatus, including:
a receiving unit, configured to receive a block repair command, where the block repair command includes: the method comprises the steps of obtaining block height indication information of a block to be repaired, source block data and target block data, wherein the block to be repaired is a block which is allowed to be repaired in a block chain after voting confirmation;
a positioning unit, configured to position the block to be repaired based on the block height indication information;
a data replacement unit, configured to replace the source block data stored in the current target block with the target block data, by using the block to be repaired as the current target block;
and the updating unit is used for recalculating and updating the target block parameters of the current target block, then taking the next block of the current target block as the current target block and performing the recalculation and updating of the target block parameters of the current target block again until the target block parameters of the last block in the block chain are updated.
Based on the second aspect of the present application, in a first possible implementation manner, the block repairing apparatus further includes:
and the event recording unit is used for recording the current block repairing event in the block chain after the target block parameter of the last block is updated.
Based on the second aspect of the present application or the first possible implementation manner of the second aspect of the present application, in a second possible implementation manner, the target block parameter includes: a transaction tree root value, a receipt tree root value, a status tree root value, a block signature, and a hash pointer to a parent block;
the update unit includes:
the first sub-updating unit is used for calculating and updating the transaction tree root value of the current target block based on the hash lists of all transactions in the current target block;
the second sub-updating unit is used for calculating and updating the receipt tree root value of the current target block based on the hash list of all transaction receipts in the current target block;
the third sub-updating unit is used for calculating and updating the state tree root value of the current target block based on the hash list of all account states in the current target block;
the fourth sub-updating unit is used for updating the hash pointer pointing to the parent block in the block head of the current target block;
and the fifth sub-updating unit is used for generating and updating the block signature based on the block head content of the current target block.
In a third possible implementation manner, based on the second aspect of the present application or the first possible implementation manner of the second aspect of the present application, a committee exists in the block chain, and the committee has a voting function and a repair triggering function; the voting function comprises: when a proposal is received, triggering each member in the committee to vote at each block yield time of the N blocks which are produced later, and voting the proposal so as to support or object the repair of the related block of the proposal, wherein each proposal comprises: the method comprises the following steps of (1) indicating information of block height, source block data, target block data and repair reasons, wherein N is a preset value larger than 2;
the repair trigger function includes: counting all votes of each member in the committee on the proposal after the last vote on the proposal is finished; when the accumulated number of supported tickets aiming at the proposal is more than the accumulated number of anti-tickets, outputting a corresponding block repair instruction based on the proposal;
the receiving unit is specifically configured to receive a block repair command from the committee.
A third aspect of the present application provides a block repairing apparatus, which includes a memory and a processor, where the memory stores a computer program, and the processor implements the steps of the block repairing method in the first aspect or any possible implementation manner of the first aspect when executing the computer program.
A fourth aspect of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program, when executed by a processor, implements the steps of the block repairing method mentioned in the first aspect or any of the possible implementation manners of the first aspect.
As can be seen from the above, according to the technical scheme of the present application, under the trigger of a corresponding block repair instruction, a target block data is used to replace source block data in a block to be repaired (i.e., a block allowed to be repaired is confirmed by voting), and target block parameters of the block to be repaired and a block generated thereafter are recalculated and updated, so as to achieve the effect of deleting and modifying part of block data.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a block chain structure diagram after hard bifurcation repair according to the present application;
fig. 2 is a flowchart illustrating an embodiment of a block repair method according to the present disclosure;
fig. 3a and fig. 3b are schematic diagrams of a voting mechanism scenario provided in the present application;
FIG. 4 is a schematic diagram of a transaction tree root calculation process provided herein;
fig. 5 is a schematic diagram of a block repair scenario provided in the present application;
fig. 6 is a schematic structural diagram of an embodiment of a block repair apparatus provided in the present application;
fig. 7 is a schematic structural diagram of another embodiment of a block repair device provided in the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it should be understood that the described embodiments are a part of the embodiments of the present application, and not all of the embodiments, and the present application is not limited by the embodiments described below.
In the specification and drawings, elements are described in singular or plural according to embodiments. However, the singular and plural forms are appropriately selected for the proposed cases only for the sake of explanation without intending to limit the present application thereto. Thus, the singular may include the plural and the plural may also include the singular, unless the context clearly dictates otherwise.
Embodiments of the present application relate to block chain technology, and some concepts related to the embodiments of the present application will be described below for the sake of understanding.
Block chains: the block chain data structure takes blocks (blocks) confirmed by a consensus mechanism as basic units, data in the block chain are distributed in the blocks which are connected in time, the Hash (Hash) value of the previous block is recorded in the next block, whether each block (and transaction in the block) is legal or not can be quickly checked in a way of calculating the Hash value, and the block chain data structure has the characteristics of being not falsifiable, open and transparent.
Block: data elements in the blockchain to record all transaction data and status results, etc. that occur over a period of time. The structure of each block is divided into two parts, a block head and a block body. The block head mainly comprises the following parts: version, prevBlockHash, merkleRoot, time difficiltyTarget, nonce. version: the version number of the block header is recorded and is used for tracking the update of the software/protocol; prevBlockHash: record the Hash address of the last block of the block (i.e., the Hash pointer to the parent block); merkleRoot: records the hash value (such as transaction root value, receipt root value, status root value) of the merkel root (i.e. merkle root) in the block; time: recording the creation time stamp of the block; difficiltytarget: recording the block chain workload certification difficulty target; and (4) nonce: the calculation parameters for proving the workload are recorded. The contents of the tile block are the transaction information for the tile, including the transaction amount and transaction data (also referred to as tile data).
Transaction tree root value: the hash value of the transaction tree root, and the transaction tree is used for recording the state and the change of the transaction. Each tile has a respective transaction tree.
Receipt tree root value: a hash of a receipt tree used to store transaction receipts.
State tree root value: the hash value and the state number of the state tree are used for storing various states in the account, such as balance and the like.
Node (or node device): a finger may join a blockchain as a node of the blockchain by running an installation of a node protocol program following a corresponding node protocol.
A supervision mechanism: for entity organization or individuals who perform industry or service supervision on a supervised party, a supervision mechanism can correspond to one equipment terminal or server, and can also correspond to a plurality of equipment terminals or servers as node equipment of a corresponding block chain;
committee: the system comprises a mechanism with voting and election functions and restoration triggering functions, wherein members of committees can be generated in an election mode, and each member of the committees can correspond to a node device in a block chain.
And (3) deposit and certificate transaction: the real data generated by the physical world by the nodes in the block chain can be constructed into a standard transaction format supported by the block chain, then the real data is issued to the block chain, the received transaction is subjected to consensus processing by the nodes in the block chain, after consensus confirmation is achieved, the transaction is packaged (namely stored) into the block by the accounting nodes in the block chain, and persistent evidence is stored in the block of the block chain.
Accounting node/mining node (validator/miner): the nodes participating in consensus in the blockchain contribute strength to achieving consensus.
Consensus: typical consensus mechanisms of the algorithms for achieving consistency in the distributed system include proof of work (pow), proof of stop (pos), byzantine Fault Tolerance (BFT), and the like.
And (3) hash value: also called information characteristic value or characteristic value, a hash value is generated by converting input data of an arbitrary length into a password by a hash algorithm and fixedly outputting, and original input data cannot be retrieved by decrypting the hash value, which is a one-way encryption function. In a blockchain, each block (except the original block) contains the hash value of the previous block, which is referred to as the parent block of the current block. Hash values are the core foundation and most important aspect of the potential in blockchain technology, which preserves the authenticity of the record and view data, as well as the integrity of the blockchain as a whole.
Fig. 2 is a schematic flow chart of a block repairing method provided in the present application, including:
step 101, receiving a block repair instruction;
wherein the block repair instruction comprises: the block height indication information of the block to be repaired (for indicating the block height of the block to be repaired), the source block data (i.e. the transaction data that needs to be repaired), and the target block data (i.e. the new transaction data for replacing the source block data), which are blocks in the block chain that are allowed to be repaired through voting confirmation.
In the embodiment of the application, a monitoring mechanism can monitor the transaction data on the block chain to determine whether the transaction carrying information is in compliance, and when the transaction carrying information is determined to be out of compliance, the related proposal can be submitted to a proposal pool to apply for deleting the out-of-compliance transaction. Specifically, the proposal may include: block height indication information (indicating the block height of the block in which the non-compliant transaction is located), source block data (i.e., transaction data for non-compliant transactions), target block data (i.e., new transaction data to replace the source block data), and repair reasons (e.g., violation information). The proposal entering the proposal pool is voted to determine whether the block to be repaired is allowed to be repaired, and when it is determined that the block to be repaired is allowed to be repaired, any member or a specific member (e.g. chairman) of the committee can send a block repair command for the block to be repaired to the execution subject (e.g. mining node, abbreviated as miner) of the embodiment, and step 101 is specifically represented as receiving the block repair command from the committee. Specifically, whether the transaction carried information is compliant or not can be determined by comparing the binary information carried in the Extra field of the transaction with the existing sensitive information database, and certainly, whether the transaction carried information is compliant or not can also be determined by the existing text and picture recognition technology or the artificial intelligence technology, which is not limited herein.
Further, the voting for the block to be repaired may be performed by a committee. As mentioned above, the committee has a voting function and a repair triggering function. The voting function comprises: when a proposal is received, triggering each block yield time of the N blocks produced by each member in the committee (in the embodiment, the time period of each block yield time of the N blocks is referred to as a voting window period), and voting for the proposal so as to support or object the repair of the related block of the proposal. That is, the committee member continuously votes in N blocks of the voting window period, and performs the vote counting work when the last block of the voting window period is completed, so as to reduce the condition that some members of the committee do bad or are not online, wherein N is a preset value larger than 2. It should be noted that: members in the committee can not judge whether the source block data contained in the proposal is illegal by null, but can recover the evidence provided by the proposal from the block to be repaired, and judge whether the source block data in the proposal is in compliance, and certainly, whether the compliance is in some fuzzy conditions exists, so that the members in each committee can judge and vote.
The repair trigger function includes: counting all votes of each member in the committee on the proposal after the last vote on the proposal is finished; and when the accumulated support ticket number aiming at the proposal is more than the accumulated objection ticket number, outputting a corresponding block repair instruction based on the proposal. In order that the blockchain state does not cause divergence, the inability to submit new common transactions in the blockchain may be limited during the voting window period described above.
To facilitate a better understanding of the voting mechanism, the committee-based voting mechanism is described below with reference to the scene diagrams shown in fig. 3a and 3 b. H-1, H +1, H +2, H +3, and H +4 represent the block height at which blocks A1-A6 are located, respectively, and ID1, ID2, and ID3 are the proposals that have been committed to the proposal pool. Assuming that the supervising authority confirms that there is an out-of-compliance transaction for block A2 by monitoring, as shown in fig. 3a, the proposal ID3 associated with block A2 is submitted to the proposal pool, and as shown in fig. 3b, the committee receives the proposal ID3 from the proposal pool and triggers each block yield time (corresponding to block heights H +1, H +2, H +3 and H + 4) of the 4 blocks (i.e., N takes 4) that are subsequently yielded by each member in the committee to vote on the proposal ID3 to support or object to repair the associated block A2 of the proposal ID 3. After the final voting of the voting window period, all the members of the statistical committee vote to the proposal ID3, when the accumulated number of the supported votes for the proposal ID3 is more than the accumulated number of the objected votes, the block A2 is determined as a block which is allowed to be repaired, at this moment, a corresponding block repairing instruction is output based on the proposal ID3, and if the accumulated number of the supported votes for the proposal ID3 is less than the accumulated number of the objected votes, the block corresponding to the proposal ID3 can not be repaired. In the actual voting process, each committee member may cast 3 supporting votes and 1 deprecating vote in 4 blocks, in which case the member's final voting opinion is positive, the principle is that the final voting result is consistent with the result of the accumulated votes.
102, positioning the block to be repaired based on the block height indication information;
since the block height corresponds to the position of the block in the block chain, the block height indication information in the block repair instruction may be located to the corresponding block to be repaired, such as block A2 in fig. 3 b.
Step 103, taking the block to be repaired as a current target block, and replacing the source block data stored in the current target block with the target block data.
Step 104, recalculating and updating the target block parameters of the current target block;
the target block parameter is a parameter related to the block data stored in the relevant block in the block parameters, where the correlation means that the value of the target block parameter is directly or indirectly calculated based on the block data stored in the corresponding block. Such as the transaction tree root calculation process diagram shown in FIG. 4, H A ~H P A hash list representing all transactions in a block, a new hash value, e.g. H, is obtained by continuously concatenating adjacent hash values into one and hashing again AB =Hash(H A ,H B ). The above process is repeated continuously, and finally a unique hash value is obtained, which is the transaction number. The construction of the status Tree root and receipt Tree is identical to that described above, except that H A Hp is the hash value of all account states and the hash value of all transaction receipts, respectively. Therefore, in the Merkel tree, as long as one hash value is changed, the last calculated Merkel root is changed, and all the Merkel roots need to be recalculated. The block signature is a signature of the content of the block header and is related to the content of the block header; the hash pointer to the parent block is associated with the hash value of the parent block.
Therefore, in the embodiment of the present application, the transaction tree root, the receipt tree root, the status tree root, the block signature, and the hash pointer pointing to the parent block may be set as target block parameters, and in step 104, these target block parameters are recalculated, and other information in the block (such as the existing nonce value, the timestamp, the block height, and other data in the block except the source block data) is retained.
Specifically, step 104 may include:
calculating and updating a transaction tree root value of the current target block based on the hash lists of all transactions in the current target block;
calculating and updating a receipt tree root value of the current target block based on the hash list of all transaction receipts in the current target block;
calculating and updating a state tree root value of the current target block based on the hash list of all account states in the current target block;
updating a hash pointer pointing to a parent block in a block head of the current target block;
a block signature is generated and updated based on the block header content of the current target block.
Step 105, taking the next block of the current target block as the current target block, and returning to execute step 104 until the target block parameter of the last block in the block chain is updated.
Based on the embodiment shown in fig. 3B, taking fig. 5 as an example for schematic illustration, as can be seen from fig. 5, after the block A2 is repaired, the block B2 is obtained, then the next block A3 of the block A2 is taken as the current target block, and the process returns to step 104 until the target block parameter of the last block A6 in the block chain is updated, so as to obtain the blocks B3 to B6, that is, after the block repairing method of the present application, the block of the block chain is updated from the blocks A1-A2-A3-A4-A5-A6 to the blocks A1-B2-B3-B4-B5-B6, and since the original structure of the block chain is not changed, the next block is produced after B6, such as the block B7 shown in fig. 5, and the corresponding block height is H +5.
Further, in order to make the current repair event perceivable, after all subsequent block updates are completed, the block repair method in the embodiment of the present application further includes: and recording the current block repairing event in the block chain. Specifically, a new block (e.g., block B7 shown in fig. 5) may be generated after the voting window period, and a transaction is constructed to record the block repair event, and generally, the recordable contents may include the block states A2 to A6 before repair and the block states B2 to B6 after repair.
As can be seen from the above, in the embodiment of the present application, for a block to be repaired (i.e., a block allowed to be repaired is confirmed by voting), under the trigger of a corresponding block repair instruction, the target block data replaces the source block data in the block to be repaired, and the target block parameters of the block to be repaired and the block generated thereafter are recalculated and updated, so as to achieve the effect of deleting and modifying part of the block data. In addition, since the block to be repaired is the block allowed to be repaired by voting confirmation in the block chain, the block repairing method achieves consensus through most node elections in the block chain.
An embodiment of the present invention further provides a block repairing apparatus, as shown in fig. 6, the block repairing apparatus 500 includes:
a receiving unit 501, configured to receive a block repair command, where the block repair command includes: the method comprises the steps of obtaining block height indication information of a block to be repaired, source block data and target block data, wherein the block to be repaired is a block which is allowed to be repaired through voting confirmation in a block chain;
a positioning unit 502, configured to position the block to be repaired based on the block height indication information;
a data replacement unit 503, configured to replace the source block data stored in the current target block with the target block data by using the block to be repaired as the current target block;
an updating unit 504, configured to recalculate and update the target block parameter of the current target block, and then take the next block of the current target block as the current target block and perform the above-mentioned operation of recalculating and updating the target block parameter of the current target block again until the target block parameter of the last block in the block chain is updated.
Optionally, the block repairing apparatus further includes:
and the event recording unit is used for recording the current block repairing event in the block chain after the target block parameter of the last block is updated.
Optionally, the target block parameter includes: a transaction tree root value, a receipt tree root value, a status tree root value, a block signature, and a hash pointer to a parent block;
the update unit 504 includes:
the first sub-updating unit is used for calculating and updating the transaction tree root value of the current target block based on the hash lists of all transactions in the current target block;
the second sub-updating unit is used for calculating and updating the receipt tree root value of the current target block based on the hash list of all transaction receipts in the current target block;
the third sub-updating unit is used for calculating and updating the state tree root value of the current target block based on the hash list of all account states in the current target block;
the fourth sub-updating unit is used for updating the hash pointer pointing to the parent block in the block head of the current target block;
and the fifth sub-updating unit is used for generating and updating the block signature based on the block head content of the current target block.
Optionally, as mentioned in the foregoing method embodiment, there is a committee in the block chain, and the committee has a voting function and a repair triggering function;
the voting function comprises: when a proposal is received, triggering each block yield time of N blocks produced later by each member in the committee to vote on the proposal so as to support or object the repair of the related block of the proposal, wherein each proposal comprises: block height indication information, source block data, target block data and repair reasons;
the repair trigger function includes: counting all votes of each member in the committee on the proposal after the last vote on the proposal is finished; when the accumulated number of the supported tickets aiming at the proposal is more than the accumulated number of the objected tickets, outputting a corresponding block repair instruction based on the proposal;
the receiving unit 501 is specifically configured to receive a block repair command from the committee.
As can be seen from the above, in the embodiment of the present application, for a block to be repaired (i.e., a block allowed to be repaired is confirmed by voting), under the trigger of a corresponding block repair instruction, the target block data replaces the source block data in the block to be repaired, and the target block parameters of the block to be repaired and the block generated thereafter are recalculated and updated, so as to achieve the effect of deleting and modifying part of the block data.
The present application also provides another block repairing apparatus, as shown in fig. 7, the cross-chain evidence storing apparatus includes: a memory 601, a processor 602, and a computer program stored in the memory 601 and executable on the processor 602, wherein: the memory 601 is used to store software programs and modules, the processor 602 executes various functional applications and data processing by operating the software programs and modules stored in the memory 601, and the memory 601 and the processor 602 are connected by a bus.
Specifically, the processor 602 implements the following steps by running the above-mentioned computer program stored in the memory 601:
receiving a block repair command, wherein the block repair command comprises: the method comprises the steps of obtaining block height indication information of a block to be repaired, source block data and target block data, wherein the block to be repaired is a block which is allowed to be repaired in a block chain after voting confirmation;
positioning the block to be repaired based on the block height indication information;
taking the block to be repaired as a current target block, and replacing the source block data stored in the current target block with the target block data;
recalculating and updating target block parameters of the current target block, wherein the target block parameters are parameters related to block data stored in a related block in the block parameters;
and taking the next block of the current target block as the current target block, and returning to the step of recalculating and updating the target block parameters of the current target block until the target block parameters of the last block in the block chain are updated.
Assuming that the above is the first possible implementation manner, in a second possible implementation manner based on the above first possible implementation manner, the processor 602 further implements the following steps by running the above computer program stored in the memory 601:
and after the target block parameter of the last block is updated, recording the current block repairing event in the block chain.
In a third possible implementation manner based on the first possible implementation manner or the second possible implementation manner, the target block parameter includes: a transaction tree root value, a receipt tree root value, a status tree root value, a block signature, and a hash pointer to a parent block;
the recalculating and updating the target block parameters of the current target block comprises:
calculating and updating a transaction tree root value of the current target block based on the hash lists of all transactions in the current target block;
calculating and updating a receipt tree root value of the current target block based on the hash list of all transaction receipts in the current target block;
calculating and updating a state tree root value of the current target block based on the hash list of all account states in the current target block;
updating a hash pointer pointing to a parent block in a block head of the current target block;
a block signature is generated and updated based on the block header content of the current target block.
In a fourth possible embodiment based on the first possible embodiment or the second possible embodiment, a committee is present in the block chain, and the committee has a voting function and a repair triggering function; the voting function comprises: when a proposal is received, triggering each block yield time of N blocks produced later by each member in the committee to vote on the proposal so as to support or object the repair of the related block of the proposal, wherein each proposal comprises: the method comprises the following steps of (1) indicating information of block height, source block data, target block data and repair reasons, wherein N is a preset value larger than 2;
the repair triggering function includes: counting all votes of each member in the committee on the proposal after the last vote on the proposal is finished; when the accumulated number of the supported tickets aiming at the proposal is more than the accumulated number of the objected tickets, outputting a corresponding block repair instruction based on the proposal;
the received block repair command includes: a block repair command is received from the committee.
As can be seen from the above, in the embodiment of the present application, for a block to be repaired (i.e., a block allowed to be repaired is confirmed by voting), under the trigger of a corresponding block repair instruction, the target block data replaces the source block data in the block to be repaired, and the target block parameters of the block to be repaired and the block generated thereafter are recalculated and updated, so as to achieve the effect of deleting and modifying part of the block data.
The present application further provides a computer-readable storage medium, on which a computer program is stored, which, when executed, may implement the steps provided by the above-described method embodiments. Specifically, the computer program includes computer program code, which may be in one of a source code form, an object code form, an executable file or some intermediate form, and is not limited herein; the computer readable storage medium can be any entity or device capable of carrying the computer program code, recording medium, U disk, removable hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random Access Memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium, and is not limited herein. It should be noted that the contents of the computer-readable storage medium can be increased or decreased as required by the legislation and patent practice in the jurisdiction.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned functions may be distributed as different functional units and modules according to needs, that is, the internal structure of the apparatus may be divided into different functional units or modules to implement all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
It should be noted that, the methods and the details thereof provided in the foregoing embodiments may be combined with the apparatuses provided in the embodiments, which are referred to each other and are not described again.
Those of ordinary skill in the art would appreciate that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.

Claims (10)

1. A method for block repair, comprising:
receiving a block repair instruction, wherein the block repair instruction comprises: the method comprises the steps that block height indication information, source block data and target block data of a block to be repaired are obtained, the time interval of each block yield moment of the produced blocks after a block repairing instruction is received is used as a voting window period, new common transactions are refused to be submitted in a block chain in the voting window period, N is a positive integer greater than or equal to 2, and the block to be repaired is a block which is allowed to be repaired in the block chain after voting confirmation;
positioning the block to be repaired based on the block height indication information;
taking the block to be repaired as a current target block, and replacing the source block data stored in the current target block with the target block data;
recalculating and updating target block parameters of the current target block, wherein the target block parameters are parameters related to block data stored in a related block in the block parameters;
and taking the next block of the current target block as the current target block, and returning to the step of recalculating and updating the target block parameters of the current target block until the target block parameters of the last block in the block chain are updated.
2. The block repair method of claim 1, wherein after the target block parameter of the last block is updated, the block repair method further comprises:
and recording the block repairing event in the block chain.
3. The block repair method according to claim 1 or 2, wherein the target block parameters include: a transaction tree root value, a receipt tree root value, a status tree root value, a block signature, and a hash pointer to a parent block;
the recalculating and updating the target block parameters of the current target block comprises:
calculating and updating a transaction tree root value of the current target block based on the hash lists of all transactions in the current target block;
calculating and updating a receipt tree root value of the current target block based on the hash list of all transaction receipts in the current target block;
calculating and updating a state tree root value of the current target block based on the hash list of all account states in the current target block;
updating a hash pointer pointing to a parent block in a block head of the current target block;
a block signature is generated and updated based on the block header content of the current target block.
4. The block repair method according to claim 1 or 2, wherein a committee exists in the block chain, the committee having a voting function and a repair triggering function; the voting function comprises: upon receiving a proposal, triggering members of the committee to vote at each block yield time of the N blocks subsequently yielded for the proposal in favor of or against the repair of the associated block of the proposal, wherein each proposal comprises: the method comprises the following steps of (1) indicating information of block height, source block data, target block data and repair reasons, wherein N is a preset value larger than 2;
the repair triggering function includes: counting all votes by members of the committee for the proposal after the last vote for the proposal is over; when the accumulated number of supported votes is more than the accumulated number of anti-votes for the proposal, outputting a corresponding block repair instruction based on the proposal;
the received block repair instruction specifically includes: a block repair instruction is received from the committee.
5. A block repair apparatus, comprising:
a receiving unit, configured to receive a block repair instruction, where the block repair instruction includes: the method comprises the steps that block height indication information, source block data and target block data of a block to be repaired are obtained, the time interval of each block yield moment of N blocks which are produced after a block repairing instruction is received is used as a voting window period, new common transactions are refused to be submitted in a block chain in the voting window period, N is a positive integer which is greater than or equal to 2, and the block to be repaired is a block which is allowed to be repaired in the block chain after voting confirmation;
the positioning unit is used for positioning the block to be repaired based on the block height indication information;
the data replacement unit is used for replacing the source block data stored in the current target block with the target block data by taking the block to be repaired as the current target block;
and the updating unit is used for recalculating and updating the target block parameters of the current target block, then taking the next block of the current target block as the current target block and performing the actions of recalculating and updating the target block parameters of the current target block again until the target block parameters of the last block in the block chain are updated.
6. The block repair device of claim 5, further comprising:
and the event recording unit is used for recording the current block repairing event in the block chain after the target block parameter of the last block is updated.
7. The block repair device according to claim 5 or 6, wherein the target block parameters include: a transaction tree root value, a receipt tree root value, a status tree root value, a block signature, and a hash pointer to a parent block;
the update unit includes:
the first sub-updating unit is used for calculating and updating the transaction tree root value of the current target block based on the hash lists of all transactions in the current target block;
the second sub-updating unit is used for calculating and updating the receipt tree root value of the current target block based on the hash list of all transaction receipts in the current target block;
the third sub-updating unit is used for calculating and updating the state tree root value of the current target block based on the hash list of all account states in the current target block;
the fourth sub-updating unit is used for updating the hash pointer pointing to the parent block in the block head of the current target block;
and the fifth sub-updating unit is used for generating and updating the block signature based on the block header content of the current target block.
8. The block recovery device according to claim 5 or 6, wherein there is a committee in the block chain, said committee having voting function and recovery triggering function; the voting function comprises: when a proposal is received, triggering each member in the committee to vote at each block yield time of the N blocks which are produced later on, and voting for the proposal so as to support or object that the relevant block of the proposal is repaired, wherein each proposal comprises: the method comprises the following steps of (1) indicating information of block height, source block data, target block data and repair reasons, wherein N is a preset value larger than 2;
the repair trigger function includes: counting all votes by members of the committee for the proposal after the last vote for the proposal is over; when the accumulated number of supported votes is more than the accumulated number of anti-votes for the proposal, outputting a corresponding block repair instruction based on the proposal;
the receiving unit is specifically configured to receive a block repair instruction from the committee.
9. A block repair apparatus includes a memory and a processor;
the memory stores a computer program, and the processor implements the steps of the block repair method according to any one of claims 1 to 4 when executing the computer program.
10. A computer-readable storage medium, in which a computer program is stored, which, when being executed by a processor, carries out the steps of the block repair method according to any one of claims 1 to 4.
CN202011601364.7A 2020-12-29 2020-12-29 Block repairing method and related device Active CN112650734B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011601364.7A CN112650734B (en) 2020-12-29 2020-12-29 Block repairing method and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011601364.7A CN112650734B (en) 2020-12-29 2020-12-29 Block repairing method and related device

Publications (2)

Publication Number Publication Date
CN112650734A CN112650734A (en) 2021-04-13
CN112650734B true CN112650734B (en) 2023-03-24

Family

ID=75364227

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011601364.7A Active CN112650734B (en) 2020-12-29 2020-12-29 Block repairing method and related device

Country Status (1)

Country Link
CN (1) CN112650734B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018234922A1 (en) * 2017-06-19 2018-12-27 nChain Holdings Limited Computer-implemented system and method for time release encryption over a blockchain network

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109241192B (en) * 2018-09-18 2021-06-15 百度在线网络技术(北京)有限公司 Data modification and block verification method, device, equipment and medium for block chain
CN109213900B (en) * 2018-09-18 2020-10-16 百度在线网络技术(北京)有限公司 Data modification method, device, equipment and medium for block chain
CN110489422B (en) * 2019-08-23 2022-04-08 电子科技大学 Automatic block chain repairing method
CN111679936B (en) * 2020-05-26 2023-09-05 中国工商银行股份有限公司 Automatic block chain network bifurcation recovery method, device and system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018234922A1 (en) * 2017-06-19 2018-12-27 nChain Holdings Limited Computer-implemented system and method for time release encryption over a blockchain network

Also Published As

Publication number Publication date
CN112650734A (en) 2021-04-13

Similar Documents

Publication Publication Date Title
US20210216623A1 (en) Blockchain implemented counting system and method for use in secure voting and distribution
CN109543065B (en) Video active identification method combined with block chain
CN107181797B (en) Block compression method and system of block chain
JP2022549581A (en) Computing system, method, non-transitory computer-readable medium and computer program product for determining the sequential order of blocks in a DAG-structured blockchain
CN110602125B (en) Data processing method, device, terminal and storage medium
CN110602217B (en) Block chain-based alliance management method, device, equipment and storage medium
CN108009445B (en) Semi-centralized trusted data management system
CN110390524B (en) Method and device for processing job data in block chain, electronic equipment and storage medium
CN111556115B (en) Block chain-based data processing method, device, equipment and storage medium
CN110912705B (en) Distributed electronic voting method and system based on block chain
CN109658099B (en) Account book accounting method based on block chain
CN111915294A (en) Safety, privacy protection and tradable distributed machine learning framework based on block chain technology
CN113950679A (en) Validating a measurement dataset using speaker consensus
CN110599384A (en) Organization relation transfer method, device, equipment and storage medium
CN111865595A (en) Block chain consensus method and device
CN112699136B (en) Cross-link certificate storage method and related device
CN111861737B (en) Block chain-based wind control model optimization method and device and computer equipment
EP3472779A1 (en) Digital asset platform
CN112650734B (en) Block repairing method and related device
CN111881147B (en) Processing method and device of computing task, storage medium and processor
US11362806B2 (en) System and methods for recording codes in a distributed environment
CN111817859A (en) Data sharing method, device, equipment and storage medium based on zero knowledge proof
WO2023019841A1 (en) Data audit method and apparatus
Costa et al. A blockchain using proof-of-download
CN114650289B (en) Method and device for block chain consensus

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
GR01 Patent grant
GR01 Patent grant